我正在尝试制作一个使用 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/