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. QAndroidJniObject::getStaticObjectField ... problems
Forum Updated to NodeBB v4.3 + New Features

QAndroidJniObject::getStaticObjectField ... problems

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 374 Views
  • 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.
  • A Offline
    A Offline
    Ar2uR
    wrote on last edited by
    #1

    Hi kind reader. I trying to get my head around QT +Android.
    Writing app to work with IOT (ESP-32) but Qt didn't have a wrapper for manage WiFi, so JNI is my only option here.

    My goal is to check the current connection, status BSSID etc. Next disconnect from it connect to hidden SSID of IOT ( when i setup mode ) ask the user for the password for this AP pass BSSID and password as a config to IOT, disconnect from IOT when it restarts Delete it from Android BSSID list and reconnects to origin BSSID.
    But as always I hit the wall, QAndroidJniObject didn't want to play with me.

    QAndroidJniObject activity = QAndroidJniObject::callStaticObjectMethod("org/qtproject/qt5/android/QtNative", "activity", "()Landroid/app/Activity;");
    if ( activity.isValid() )
    {
        QAndroidJniObject serviceName = QAndroidJniObject::getStaticObjectField<jstring>("android/content/Context","WIFI_SERVICE");
        if ( serviceName.isValid() ){
    
            QAndroidJniObject wifiMgr = activity.callObjectMethod("getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;",serviceName.object<jobject>());
            if ( wifiMgr.isValid() ){
    
                jint wifiStateEnabled = QAndroidJniObject::getStaticField<jint>("android/net/wifi/WifiManager","WIFI_STATE_ENABLED");
    
               QAndroidJniObject j_String = QAndroidJniObject::getStaticObjectField("android/net/wifi/WifiManager","EXTRA_WIFI_INFO","()Ljava/lang/String;");
    
                qDebug() << " extra info=" <<  j_String.toString() << "Wifi_State =" << wifiStateEnabled ; // wifi  enabled =3 
            }
        }
       }
    

    and I geting this ..

    from app Output ...
    I Timeline: Timeline: Activity_idle id: android.os.BinderProxy@b2ee161 time:601456834
    I ViewRootImpl: ViewRoot's Touch Event : ACTION_DOWN
    I ViewRootImpl: ViewRoot's Touch Event : ACTION_UP
    W System.err: java.lang.NoSuchFieldError: no type "()Ljava/lang/String;" found and so no field "EXTRA_WIFI_INFO" could be found in class "Landroid/net/wifi/WifiManager;" or its superclasses
    W System.err: at org.qtproject.qt5.android.QtNative.startQtApplication(Native Method)
    W System.err: at org.qtproject.qt5.android.QtNative$7.run(QtNative.java:387)
    W System.err: at org.qtproject.qt5.android.QtThread$1.run(QtThread.java:61)
    W System.err: at java.lang.Thread.run(Thread.java:818)
    W System.err: Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack trace available
    D libQT_Android_Java_Test.so: extra info= "" Wifi_State = 3

    I can get staticField when it is primitive type but when trying to access string or object no type found ... no field.
    any idea how to access this

    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