[英]How to Setup WiFi-Tethering to Android Things for Raspberry Pi3
我嘗試了這段代碼,但它不起作用。 聽到錯誤信息。
引起:java.lang.SecurityException:com.example.androidthings.myproject 沒有被授予這個權限: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"
謝謝
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.