Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android ConnectivityManager is not seeing permission ACCESS_NETWORK_STATE

I have simple code that wants to read the state of network connection. I've added permission to the AndroidManifest.xml:

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

My code that tries to access network state:

    ConnectivityManager conmgr = (ConnectivityManager) ctx.getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo ninfo = conmgr.getActiveNetworkInfo();

And the error that is thrown:

 E/AndroidRuntime(7650): java.lang.SecurityException: ConnectivityService: Neither user 10080 nor current process has android.permission.ACCESS_NETWORK_STATE.

I've long tried to find any error, but everything seems to be spelled correctly. It seems like the new version of AndroidManifest is not deployed to device. I've tried to clean project in Eclipse, uninstall app from phone, but nothing is working, I get the same communicate again. What I'm doing wrong?

like image 445
Danubian Sailor Avatar asked Feb 21 '12 10:02

Danubian Sailor


Video Answer


1 Answers

I think it is

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

instead of

<user-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
like image 145
MobileCushion Avatar answered Nov 15 '22 20:11

MobileCushion