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);
try{
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);
}
}
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"/>
Thank you for your cooperation
android raspberry-pi
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.
https://developer.android.com/reference/android/Manifest.permission.html
Understanding Permission Issues in WRITE_SETTINGS
I have a similar question below, and it seems that it has been solved.
https://stackoverflow.com/questions/32083410/cant-get-write-settings-permission
575 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
926 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
586 PHP ssh2_scp_send fails to send files as intended
621 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.