android - 请求互联网许可不起作用
问题描述
我正在尝试使用 SDK 26 在我的 android 手机上的我的 android 应用程序中请求互联网许可。我尝试使用AndroidManifest.xml
,我尝试使用ActivityCompat.requestPermissions(this, new String[]{ Manifest.permission.INTERNET }, 1);
并且我尝试了不同的请求代码。我已经在onCreate
按钮按下事件中和内部进行了尝试,但是当我进入应用程序信息时仍然没有显示权限。
我完全迷失了,因为我看不出有任何理由为什么这不起作用。有任何想法吗?我还不知道的常见问题?
andoidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.simplevents">
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
解决方案
权限分为几个保护级别
影响第三方应用程序的保护级别有三个:正常、签名和危险权限
INTERNET
权限处于正常保护级别,这就是为什么不需要在运行时询问
在这里查看列表
什么是正常和危险的许可?
正常:
对用户不敏感和有害的权限,例如。像振动和互联网
危险:
敏感和有害的权限,如允许READ_CONTACTS后,应用程序可能会滥用您的联系人详细信息或允许READ_EXTERNAL_STORAGE访问您的 SD 卡数据
推荐阅读
- node.js - 即使在使用 nvm 安装节点后,firebase cli 也会出现 EACCES 权限错误
- sql - SQL Array concat agg 与计数?
- sql - 在所有关联行的另一列中选择 PO_ID 具有特定值的行
- javascript - 如何听 div 的高度变化?
- c++ - 位操作在这里有什么优势吗?
- c++ - 什么是公共的、私有的、受保护的?
- angular - Angular PathLocationStrategy 刷新页面不起作用
- react-native - 如何在开玩笑的反应原生地图中测试 MapView 的 onRegionChangeComplete 中的回调?
- java - GCP 云功能可以访问(写入)/src/main/resources 吗?
- c++ - CPP 到 Delphi 转换