コード例 #1
0
 public void requestInternetPermission() {
   if (ActivityCompat.shouldShowRequestPermissionRationale(
       activity, Manifest.permission.INTERNET)) {
     permissionCallback.onPermissionExplanationRequired(true, Manifest.permission.INTERNET);
   } else {
     ActivityCompat.requestPermissions(
         activity, new String[] {Manifest.permission.INTERNET}, INTERNET_PERMISSION);
   }
 }
コード例 #2
0
 public void requestExternalStoragePermission() {
   if (ActivityCompat.shouldShowRequestPermissionRationale(
       activity, Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
     permissionCallback.onPermissionExplanationRequired(
         true, Manifest.permission.WRITE_EXTERNAL_STORAGE);
   } else {
     ActivityCompat.requestPermissions(
         activity,
         new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE},
         EXTERNAL_STORAGE_PERMISSION);
   }
 }
コード例 #3
0
 public void requestExternalStoragePermission(
     AppCompatActivity appCompatActivity, PermissionCallback callback, boolean requestFromDialog) {
   if (ActivityCompat.shouldShowRequestPermissionRationale(
           appCompatActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE)
       && !requestFromDialog) {
     callback.onPermissionExplanationRequired(true, Manifest.permission.WRITE_EXTERNAL_STORAGE);
   } else {
     ActivityCompat.requestPermissions(
         appCompatActivity,
         new String[] {Manifest.permission.WRITE_EXTERNAL_STORAGE},
         EXTERNAL_STORAGE_PERMISSION);
   }
 }