Home » Java » How to enable/disable wifi in android device through native code(java) in qt c/c++?

How to enable/disable wifi in android device through native code(java) in qt c/c++?

Posted by: admin October 28, 2018 Leave a comment

Questions:

I successfullly managed wifi enable through java code using andorid studio but not able to do same in the qt c/c++..
i have tried the java method.. it’s working perfectly in android

public static  void enableWifi(Context context){
    WifiManager wifiManager = (WifiManager) context.getSystemService(context.WIFI_SERVICE);
    wifiManager.setWifiEnabled(true);//Turn on Wifi
    }

calling from c/c++ :

QAndroidJniObject::callStaticMethod<void>("com/app/MyJavaClass",
                                                           "enableWifi",
                                                         "(Landroid/content/Context;)V",
                                                            QtAndroid::androidContext().object());

I couldn’t able to enable wifi in android device using c/c++.. how can i achieve this? please help me out…
Thanks in advance

Answers: