Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ACCESS_NETWORK_STATE permission on Android ICS

Tags:

I declared the permission ACCESS_NETWORK_STATE in Application manifest as below.

<uses-permission  android:name="android.permission.ACCESS_NETWORK_STATE"/> 

Everything is good on Android 2.x. But on Android ICS, it failed with below log cat.

 java.lang.SecurityException: ConnectivityService: Neither user 10093  nor current process has android.permission.ACCESS_NETWORK_STATE. at  android.os.Parcel.readException(Parcel.java:1327) at  android.os.Parcel.readException(Parcel.java:1281) at  android.net.IConnectivityManager$Stub$Proxy.getActiveNetworkInfo(IConnectivityManager.java:663)  at  android.net.ConnectivityManager.getActiveNetworkInfo(ConnectivityManager.java:455)  at com.tapfortap.AdView.getNetwork(AdView.java:146) at  com.tapfortap.AdView.loadAdsWithAppId(AdView.java:133) at  com.tapfortap.AdView.access$100(AdView.java:47) at  com.tapfortap.AdView$1$1.run(AdView.java:88) at  android.os.Handler.handleCallback(Handler.java:605) at  android.os.Handler.dispatchMessage(Handler.java:92) at  android.os.Looper.loop(Looper.java:137) at  android.app.ActivityThread.main(ActivityThread.java:4503) at  java.lang.reflect.Method.invokeNative(Native Method) at  java.lang.reflect.Method.invoke(Method.java:511) at  com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:809)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:576) at  dalvik.system.NativeStart.main(Native Method) 
like image 557
Nguyen Minh Binh Avatar asked Oct 08 '12 08:10

Nguyen Minh Binh


2 Answers

I updated the permissions like this and it works.

<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> 

this is because ACCESS_NETWORK_STATE is used as connectivityManger and this needs INTERNET connection.

like image 117
Nguyen Minh Binh Avatar answered Sep 20 '22 16:09

Nguyen Minh Binh


I believe this is an issue with Eclipse; it fails to refresh the manifest to load the permission.

I had the same problem as the original poster and solved it by adding the permission a second time--but then I was able to remove the permission without affecting behavior. This makes me suspect that Eclipse didn't load permissions correctly until I touched the file.

like image 22
user2259744 Avatar answered Sep 19 '22 16:09

user2259744