Android ICS的ACCESS_NETWORK_STATE权限 [英] ACCESS_NETWORK_STATE permission on Android ICS

查看:1151
本文介绍了Android ICS的ACCESS_NETWORK_STATE权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在应用清单中声明了权限ACCESS_NETWORK_STATE,如下所示.

I declared the permission ACCESS_NETWORK_STATE in Application manifest as below.

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

在Android 2.x上一切都很好.但是在Android ICS上,它失败并显示以下log cat.

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)

推荐答案

我更新了这样的权限,并且可以使用.

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" />

这是因为ACCESS_NETWORK_STATE被用作ConnectivityManger,并且需要INTERNET连接.

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

这篇关于Android ICS的ACCESS_NETWORK_STATE权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆