0

i've got a simple question. How does i request the permission INTERNET programmaticaly?

I done successfull granded CAMERA with a dialog from Android with:

private boolean hasInternetPermissions() {
    return ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED;
}

private static final int INTERET_PERMISSION = 1337;

private void requestInternetPermission() {
    if (ActivityCompat.shouldShowRequestPermissionRationale(this,
            Manifest.permission.CAMERA)) {
    } else {
        ActivityCompat.requestPermissions(this,
                new String[]{Manifest.permission.CAMERA},
                INTERET_PERMISSION);
    }
}

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
    super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}

At AndroidManifest.xml

 <uses-permission android:name="android.permission.CAMERA"/>

But why is it not working with permission INTERNET?

Thanks for your help.

user1740789
  • 249
  • 2
  • 3
  • 15
  • 1
    The `INTERNET` permission is not a dangerous permission. You don't need to request it at runtime, so it will not show in the request dialogs. – Mike M. Jan 27 '19 at 10:24
  • Thanks for your fast answer! I've read the marked post. But i dont understand why android give that permission without userprompt. – user1740789 Jan 27 '19 at 10:25
  • 1
    Only dangerous permissions require a runtime request. For whatever reason, they decided that the `INTERNET` permission was not dangerous, so you don't need to request it as such. – Mike M. Jan 27 '19 at 10:27

0 Answers0