Cannot get WiFi AP state 错误
09-08 21:14:26.890: E/ThreadApHelper(22579): Cannot get WiFi AP state
09-08 21:14:26.890: E/ThreadApHelper(22579): java.lang.reflect.InvocationTargetException
09-08 21:14:26.890: E/ThreadApHelper(22579): at java.lang.reflect.Method.invokeNative(Native Method)
09-08 21:14:26.890: E/ThreadApHelper(22579): at java.lang.reflect.Method.invoke(Method.java:507)
09-08 21:14:26.890: E/ThreadApHelper(22579): at com.leranxinsheng.net.ThreadApHelper.getWifiApState(ThreadApHelper.java:125)
09-08 21:14:26.890: E/ThreadApHelper(22579): at com.leranxinsheng.net.ThreadApHelper.isApEnabled(ThreadApHelper.java:138)
09-08 21:14:26.890: E/ThreadApHelper(22579): at com.leranxinsheng.activity.BottomMenuActivity$1.onReceive(BottomMenuActivity.java:69)
09-08 21:14:26.890: E/ThreadApHelper(22579): at android.app.LoadedApk$ReceiverDispatcher$Args.run(LoadedApk.java:709)
09-08 21:14:26.890: E/ThreadApHelper(22579): at android.os.Handler.handleCallback(Handler.java:587)
09-08 21:14:26.890: E/ThreadApHelper(22579): at android.os.Handler.dispatchMessage(Handler.java:92)
09-08 21:14:26.890: E/ThreadApHelper(22579): at android.os.Looper.loop(Looper.java:130)
09-08 21:14:26.890: E/ThreadApHelper(22579): at android.app.ActivityThread.main(ActivityThread.java:3683)
09-08 21:14:26.890: E/ThreadApHelper(22579): at java.lang.reflect.Method.invokeNative(Native Method)
09-08 21:14:26.890: E/ThreadApHelper(22579): at java.lang.reflect.Method.invoke(Method.java:507)
09-08 21:14:26.890: E/ThreadApHelper(22579): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
09-08 21:14:26.890: E/ThreadApHelper(22579): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
09-08 21:14:26.890: E/ThreadApHelper(22579): at dalvik.system.NativeStart.main(Native Method)
09-08 21:14:26.890: E/ThreadApHelper(22579): Caused by: java.lang.SecurityException: WifiService: Neither user 10104 nor current process has android.permission.ACCESS_WIFI_STATE.
09-08 21:14:26.890: E/ThreadApHelper(22579): at android.os.Parcel.readException(Parcel.java:1322)
09-08 21:14:26.890: E/ThreadApHelper(22579): at android.os.Parcel.readException(Parcel.java:1276)
09-08 21:14:26.890: E/ThreadApHelper(22579): at android.net.wifi.IWifiManager$Stub$Proxy.getWifiApEnabledState(IWifiManager.java:923)
09-08 21:14:26.890: E/ThreadApHelper(22579): at android.net.wifi.WifiManager.getWifiApState(WifiManager.java:826)
09-08 21:14:26.890: E/ThreadApHelper(22579): ... 15 more
09-08 21:14:26.890: D/AndroidRuntime(22579): Shutting down VM
原因是:没有访问WIFI状态的权限(ACCESS_WIFI_STATE)。
在AndroidManifest.xml里面加上
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
就行了。
作者:kissazi2
出处:http://www.cnblogs.com/kissazi2/
本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。