简体   繁体   中英

How to Setup WiFi-Tethering to Android Things for Raspberry Pi3

I try this code but it is not work. Error message is hear.

Caused by: java.lang.SecurityException: com.example.androidthings.myproject was not granted this permission: android.permission.WRITE_SETTINGS."

    private void wifiTetheringOn(){
    WifiManager wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    try {
        Method method = wifi.getClass().getMethod("setWifiApEnabled", WifiConfiguration.class, boolean.class);
        Log.i(TAG,method.invoke(wifi, null, true).toString());
    } catch (Exception e) {
        Log.e(TAG, "error: ", e);
    }
}

AndroidManifest.xml

    uses-permission android:name="android.permission.ACCESS_WIFI_STATE" 
    uses-permission android:name="android.permission.CHANGE_WIFI_STATE" 
    uses-permission android:name="android.permission.WRITE_SETTINGS" 

thanks

i already tried for creating Wifi tethering in raspberry PI 3 and found that currently we can not create wifi tethering for internet sharing .You can also look at my raised question at android things forum at issue tracker

You can use startLocalOnlyHotspot introduce in android 7 but it will not share internet , only allow local connection .

Reference link

NOTE : For android.permission.WRITE_SETTINGS if you set target below android 7 then it will not create exception but still i found that it does not allow any connection to that hotspot.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM