简体   繁体   English

如何为 Raspberry Pi3 设置与 Android Things 的 WiFi 网络共享

[英]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."引起: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 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我已经尝试在 raspberry PI 3 中创建 Wifi 网络共享,发现目前我们无法创建用于互联网共享的 wifi 网络共享。您也可以在问题跟踪器的android things 论坛上查看我提出的问题

You can use startLocalOnlyHotspot introduce in android 7 but it will not share internet , only allow local connection .您可以使用 android 7 中引入的startLocalOnlyHotspot但它不会共享互联网,只允许本地连接。

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.注意:对于android.permission.WRITE_SETTINGS如果您将目标设置为低于 android 7,则它不会创建异常,但我仍然发现它不允许连接到该热点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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