Security exception by accessing the wifi in android

前端 未结 3 1232
没有蜡笔的小新
没有蜡笔的小新 2021-01-11 10:28

Please see the following code

    wifi = (WifiManager) getSystemService(Context.WIFI_SERVICE);
    if (wifi.isWifiEnabled() == false)
    {
        Toast.mak         


        
3条回答
  •  独厮守ぢ
    2021-01-11 10:35

    To be able to access the wifi you need android:name="android.permission.ACCESS_WIFI_STATE" as you already know.

    If you are enabling or disabling the wifi connection you are also going to need both permissions: ACCESS_WIFI_STATE and CHANGE_WIFI_STATE

        
    
    

    That should do it for you.

提交回复
热议问题