【发布时间】:2019-02-25 07:17:23
【问题描述】:
我正在尝试使用 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>
【问题讨论】:
-
你能分享你的完整代码和logcat消息吗?
-
你不需要在运行时请求互联网权限,在清单中声明就足够了。能否请您发布您的
AndroidManifest.xml? -
internet 权限是正常的权限,没有危险,你不需要通过程序请求它,只需在 manifest 中添加即可
-
@NovoLucas 没有错误,那么您到底想从 logcat 中得到什么?
-
@lelloman 我将它添加到帖子中,我没有发现任何问题。
标签: android android-permissions