setWifiEnabled()为WRITE_SETTINGS权限抛出java.lang.SecurityException

时间:2012-12-05 00:34:28

标签: android-wifi

为什么setWifiEnabled()会为WRITE_SETTINGS权限抛出setWifiEnabled(下面的堆栈跟踪)?

java.lang.SecurityException: Permission Denial: writing com.android.providers.settings.SettingsProvider uri content://settings/system from pid=25173, uid=10148 requires android.permission.WRITE_SETTINGS
at android.os.Parcel.readException(Parcel.java:1332)
at android.os.Parcel.readException(Parcel.java:1286)
at android.net.wifi.IWifiManager$Stub$Proxy.setWifiEnabled(IWifiManager.java:1156)
at android.net.wifi.WifiManager.setWifiEnabled(WifiManager.java:971)

Android文档中未提及此权限。 是否应将WRITE_SETTINGS权限添加到清单?

1 个答案:

答案 0 :(得分:2)

是的,setWifiEnabled()会将数据写入Android设置数据库,因此需要WRTITE_SETTINGS权限。