2

我有一个(FOSS)应用程序,除其他功能外,它还可以启用和禁用 Wifi。AndroidManifest.xml 包含android.permission.CHANGE_WIFI_STATE模拟器通过的单元测试,该功能可在真实设备上运行,HTC Desire 运行 2.2.2。

SDK 版本是android:minSdkVersion="7"and android:targetSdkVersion="10",所以我不能说 Android 的较新版本。

我收到了一份崩溃报告:

java.lang.SecurityException: Permission Denial: writing com.android.providers.settings.SettingsProvider
uri content://settings/secure from pid=6191, 
uid=10114 requires android.permission.WRITE_SETTINGS

android.permission.WRITE_SETTINGS最新版本的 Android 可能需要?参考资料说该权限自 API 1 以来就存在,所以我很惊讶为什么它不在旧版本上。

用户消息很奇怪,它只是说“谎言”,所以我不确定我是否应该关注这个报告并添加android.permission.WRITE_SETTINGS.

有什么想法吗?

干杯,托斯滕

4

1 回答 1

1

That's weird, cause I needed to check exactly the same issue, so i just wrote a few lines of code doing exactly just that : enable/disable wifi and bluetooth. My conclusion: you dont need the WRITE_SETTINGS permission to toggle the wifi, nor the bluetooth for that matter.

wifi = access_wifi_state + change_wifi_state BT = bluetooth + bluetooth_admin

(with 4.2.2)

Check whether you were trying something else too, which may trigger the exception ?

于 2013-12-29T13:51:56.890 回答