简体   繁体   English

Android互联网权限被忽略

[英]Android internet permission ignored

I have an application that requires the internet permission but it doesn't seem to be working for me. 我有一个需要互联网许可的应用程序,但它似乎对我不起作用。

I added: 我补充说:

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

To the manifest (above the application tag) and when I install the app my phone says: "No permissions requested" and the permission dialog doesn't show up. 对于清单(在应用程序标签上方),当我安装该应用程序时,我的手机说:“未请求权限”,并且权限对话框未显示。

However when I replace INTERNET with CAMERA like so: 但是,当我像这样用CAMERA替换INTERNET时:

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

It works fine and shows up under the permissions tab in settings. 它工作正常,并显示在设置的“权限”选项卡下。

Any ideas? 有任何想法吗?

Thanks 谢谢

If the device is running Android 6.0 (API level 23) and the app's targetSdkVersion is 23 or higher if an app declares in its manifest that it needs a normal permission , the system automatically grants the app that permission at install time . 如果设备运行的是Android 6.0 (API级别23),并且如果应用程序在其清单中声明需要正常权限该应用程序的targetSdkVersion23或更高版本系统会在安装时自动为该应用程序授予该权限
The system does not prompt the user to grant normal permissions, and users cannot revoke these permissions. 系统不会提示用户授予普通权限,并且用户无法撤消这些权限。

As you can check in the official doc the INTERNET permission is normal. 正如您可以签入正式文档一样INTERNET权限是正常的。
Instead the CAMERA permission is dangerous . 相反, CAMERA许可很危险

You're running your app in Android SDK>=23. 您正在Android SDK> = 23中运行您的应用程序。

Internet permission is under Normal permission so it not show any permission prompt but Camera permission is under Dangerous Permission so it show permission prompt. Internet权限在“ 普通”权限下,因此不显示任何权限提示,但“摄像机”权限在“ 危险权限”下,因此显示权限提示。

If an app declares that it needs a normal permission, the system automatically grants the permission to the app. 如果应用程序声明需要正常权限,则系统会自动将权限授予该应用程序。

https://developer.android.com/guide/topics/permissions/requesting.html https://developer.android.com/guide/topics/permissions/requesting.html

Android only puts the dangerous permissions there. Android仅将危险的权限放在此处。 And since Camera is a dangerous permissions you see it in the list, and since Internet is not, you don't see it in the list. 而且由于“相机”是危险的权限,因此您会在列表中看到它,而由于没有Internet,因此您不会在列表中看到它。

Android differentiates between normal permissions (eg INTERNET) and dangerous permissions (eg CAMERA). Android区分普通权限(例如INTERNET)和危险权限(例如CAMERA)。 The User is only asked in case of dangerous permissions. 仅在危险权限的情况下才询问用户。 So the behavior you see is perfectly normal. 因此,您看到的行为是完全正常的。

https://developer.android.com/guide/topics/permissions/normal-permissions.html https://developer.android.com/guide/topics/permissions/normal-permissions.html

Only Selected permissions can be asked for user 只能要求选定权限的用户

check here which permissions can be asked by Permission manager 在此处检查权限管理器可以询问哪些权限

This usually does the trick for me: 这通常对我有用:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM