Home » Android » eclipse – Android ConnectivityManager is not seeing permission ACCESS_NETWORK_STATE

eclipse – Android ConnectivityManager is not seeing permission ACCESS_NETWORK_STATE

Posted by: admin June 15, 2020 Leave a comment

Questions:

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?

How to&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"/>