Liron Navon Liron Navon - 5 months ago 14
Android Question

android api23 internet permission | answered

I am trying to make an app that uses INTERNET permission, but I am having trouble getting it to work with API 23, i understood that i need an on run permission and so i used google to find what i need.
i stumbled upon this code:

if (ContextCompat.checkSelfPermission(this,
!= 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
new String[]{Manifest.permission.READ_CONTACTS},

// app-defined int constant. The callback method gets the
// result of the request.

from this webstite :

problem is, i need INTERNET but all the examples i found online are for contacts, it should be similar but when i replace REQUEST_CONTACTS
with REQUEST_INTERNET i get an error, what should i replace it with?

thank you for your answere, i only needed to add permission on the manifest.


For Internet, you don't need to request permission from the user. However, you do need to declare it in the application manifest file using uses-permission element.