android api23 互联网权限

标签 android

我正在尝试制作一个使用 INTERNET 许可的应用程序,但我无法让它与 API 23 一起使用,我知道我需要一个运行许可,所以我使用谷歌来查找我需要的东西。 我偶然发现了这段代码:

if (ContextCompat.checkSelfPermission(this,
                         Manifest.permission.READ_CONTACTS)
                         != PackageManager.PERMISSION_GRANTED) {

// Already declined the permission
if (ActivityCompat.shouldShowRequestPermissionRationale(this,
                                Manifest.permission.READ_CONTACTS)) {

    // Show an expanation to the user *asynchronously* -- don't block
    // this thread waiting for the user's response! After the user
    // sees the explanation, try again to request the permission.
} 
else {

    // No explanation for the first time
    ActivityCompat.requestPermissions(this,
                   new String[]{Manifest.permission.READ_CONTACTS},
                   REQUEST_CONTACTS);

    // REQUEST_CONTACTS is an
    // app-defined int constant. The callback method gets the
    // result of the request.
}

} 从这个网站:https://www.numetriclabz.com/declaring-and-handling-permissions-since-android-api-23-tutorial-2/

问题是,我需要互联网,但我在网上找到的所有示例都是针对联系人的,它应该是相似的,但是当我替换 REQUEST_CONTACTS 时 使用 REQUEST_INTERNET 时出现错误,我应该用什么替换它?


谢谢你的回答,我只需要在 list 上添加权限。

最佳答案

对于 Internet,您不需要请求用户的许可。但是,您确实需要使用 uses-permission 元素在应用程序 list 文件中声明它。

关于android api23 互联网权限,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37488832/

相关文章:

android - 尝试分离/关闭 Firestore 快照时,条件 'listenerReg != null' 始终为 'true' (Android)

android - 无法从我的 Android 应用程序获取电话号码?

javascript - 单击链接时从 Android WebView 中的 anchor 标记获取 href 值

java - 安卓日历 : first and last day of week -> zero month

java - 如何在eclipse ADT中打开项目并自动导入LIbrary Projects依赖项

Android 应用 Widget 更新新版本删除现有的 widget

android - 如何将 TabLayout 的背景颜色与工具栏匹配?

java - 安卓:在安卓模拟器上安装Wikitude

多个动态膨胀 View 的Android保存状态

android - Onclick 被多次调用