What should I do to tether WiFi on Android Things 3)?

Asked 2 months ago, Updated 2 months ago, 3 views

I tried using the code below, but it turned out to be SecurityException and could not be configured.
I set WRITE_SETTINGS for the manifest, but is it not possible to use it?

"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);
        Method method=wifi.getClass().getMethod("setWifiAppEnabled", WifiConfiguration.class, boolean.class);
        Log.i(TAG, method.invoke(wifi, null, true).toString());
    } catch(Exceptione){
        Log.e(TAG, "error:", e);


<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"/>

Thank you for your cooperation

android raspberry-pi

2022-09-30 14:28

1 Answers

The security level of WRITE_SETTINGS should have changed since Android 6.0.
You should have explicit permission from the user.
It is listed in the Note of WRITE_SETTINGS in the API reference.

Understanding Permission Issues in WRITE_SETTINGS
I have a similar question below, and it seems that it has been solved.

2022-09-30 14:28

If you have any answers or tips

© 2022 OneMinuteCode. All rights reserved.