Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Using getRssi from QAndroidJniObject (Qt Widget)
Forum Updated to NodeBB v4.3 + New Features

Using getRssi from QAndroidJniObject (Qt Widget)

Scheduled Pinned Locked Moved Mobile and Embedded
1 Posts 1 Posters 871 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    benzoni
    wrote on last edited by
    #1

    Hi guys,
    I'm currently developing an application (widget, not qml) to connect an android device to a server using wifi connection; i've already established the connection between those but i'm still figuring out how to know the strength of the connection.
    As the "official Android page says":http://developer.android.com/reference/android/net/wifi/WifiInfo.html the function i want to use is in the class WifiInfo and it's called getRssi, so i'm following "this official guide":https://www.qtdeveloperdays.com/sites/default/files/BogdanVatra_Extending_Qt_Android_Apps_with_JNI.pdf to access it from qt using QAndroidJniObject.
    I've already added QT += androidextras in my pro file and #include <QAndroidJniObject> in my cpp file, i've added this permissions in the manifest file:
    @<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>@
    and then i've added this code:
    @int value = QAndroidJniObject::callStaticMethod<jint>("android/net/wifi/WifiInfo", "getRssi", "(I)I");
    qDebug() << value;@
    but the output is always 0 (it refresh every 50 milliseconds).
    What am I doing wrong?
    Thanks a lot for the answers!

    EDIT: I've found that the problem was that the access to the folder android/net/wifi, so i've made a java file with android native code with the code of getting rssi, and i've linked to qt in the file pro, i've changed the android manifest inserting this file and i've made the access of the function in this file with the same method, and now it works. Problem solved.

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved