List of usage examples for android.content.pm PackageManager PERMISSION_DENIED
int PERMISSION_DENIED
To view the source code for android.content.pm PackageManager PERMISSION_DENIED.
Click Source Link
From source file:com.ezartech.ezar.flashlight.Flashlight.java
public void onRequestPermissionResult(int requestCode, String[] permissions, int[] grantResults) throws JSONException { for (int r : grantResults) { if (r == PackageManager.PERMISSION_DENIED) { this.callbackContext .sendPluginResult(new PluginResult(PluginResult.Status.ERROR, PERMISSION_DENIED_ERROR)); return; }//from ww w . j av a 2 s .c o m } switch (requestCode) { case CAMERA_SEC: init(this.callbackContext); break; } }
From source file:com.frostwire.android.gui.util.DangerousPermissionsChecker.java
private boolean onExternalStoragePermissionsResult(String[] permissions, int[] grantResults) { if (!Ref.alive(activityRef)) { return false; }//from w ww .ja v a 2 s . co m final Activity activity = activityRef.get(); for (int i = 0; i < permissions.length; i++) { if (grantResults[i] == PackageManager.PERMISSION_DENIED) { if (permissions[i].equals(Manifest.permission.WRITE_EXTERNAL_STORAGE) || permissions[i].equals(Manifest.permission.READ_EXTERNAL_STORAGE)) { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setIcon(R.drawable.sd_card_notification); builder.setTitle(R.string.why_we_need_storage_permissions); builder.setMessage(R.string.why_we_need_storage_permissions_summary); builder.setNegativeButton(R.string.exit, (dialog, which) -> shutdownFrostWire()); builder.setPositiveButton(R.string.request_again, (dialog, which) -> requestPermissions()); AlertDialog alertDialog = builder.create(); alertDialog.show(); return false; } } } return true; }
From source file:com.pimp.companionforband.fragments.sensors.SensorsFragment.java
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); reference = new WeakReference<Activity>(getActivity()); band2TV = (TextView) view.findViewById(R.id.band2TxtStatus); accelerometerCard = (CardView) view.findViewById(R.id.accelerometer_card); altimeterCard = (CardView) view.findViewById(R.id.altimeter_card); ambientLightCard = (CardView) view.findViewById(R.id.ambientLight_card); barometerCard = (CardView) view.findViewById(R.id.barometer_card); caloriesCard = (CardView) view.findViewById(R.id.calories_card); contactCard = (CardView) view.findViewById(R.id.contact_card); distanceCard = (CardView) view.findViewById(R.id.distance_card); gsrCard = (CardView) view.findViewById(R.id.gsr_card); gyroscopeCard = (CardView) view.findViewById(R.id.gyroscope_card); heartRateCard = (CardView) view.findViewById(R.id.heartRate_card); pedometerCard = (CardView) view.findViewById(R.id.pedometer_card); rrIntervalCard = (CardView) view.findViewById(R.id.rrInterval_card); skinTemperatureCard = (CardView) view.findViewById(R.id.skinTemperature_card); uvCard = (CardView) view.findViewById(R.id.uv_card); CardView[] cardViews = { accelerometerCard, altimeterCard, ambientLightCard, barometerCard, caloriesCard, contactCard, distanceCard, gsrCard, gyroscopeCard, heartRateCard, pedometerCard, rrIntervalCard, skinTemperatureCard, uvCard }; String[] sensors = { "Accelerometer", "Altimeter", "Ambient Light", "Barometer", "Calories", "Contact", "Distance", "GSR", "Gyroscope", "Heart Rate", "Pedometer", "RR Interval", "Skin Temperature", "UV" }; bandAllSensorsAccelerometerEventListener = new AllSensorsAccelerometerEventListener(); bandAccelerometerEventListener = new AccelerometerEventListener(); bandAltimeterEventListener = new AltimeterEventListener(); bandAmbientLightEventListener = new AmbientLightEventListener(); bandBarometerEventListener = new BarometerEventListener(); bandCaloriesEventListener = new CaloriesEventListener(); bandContactEventListener = new ContactEventListener(); bandDistanceEventListener = new DistanceEventListener(); bandGsrEventListener = new GsrEventListener(); bandGyroscopeEventListener = new GyroscopeEventListener(); bandHeartRateEventListener = new HeartRateEventListener(); bandPedometerEventListener = new PedometerEventListener(); bandRRIntervalEventListener = new RRIntervalEventListener(); bandSkinTemperatureEventListener = new SkinTemperatureEventListener(); bandUVEventListener = new UVEventListener(); for (int i = 0; i < cardViews.length; i++) { ((TextView) cardViews[i].findViewById(R.id.txtName)).setText(sensors[i]); cardViews[i].setOnClickListener(cardViewOnClickListener); }// w w w .ja v a2 s .c o m int permissionCheck = ContextCompat.checkSelfPermission(getActivity(), Manifest.permission.WRITE_EXTERNAL_STORAGE); logTV = (TextView) view.findViewById(R.id.logStatus); if (permissionCheck == PackageManager.PERMISSION_DENIED) logTV.setText(getResources().getString(R.string.permit_log)); else logTV.setText(getResources().getString(R.string.log_text)); ((Switch) view.findViewById(R.id.log_switch)) .setChecked(MainActivity.sharedPreferences.getBoolean("log", false)); if (!MainActivity.sharedPreferences.getBoolean("log", false)) view.findViewById(R.id.logStatus).setVisibility(View.GONE); else { view.findViewById(R.id.logStatus).setVisibility(View.VISIBLE); view.findViewById(R.id.backlog_switch).setVisibility(View.VISIBLE); } ((Switch) view.findViewById(R.id.backlog_switch)) .setChecked(MainActivity.sharedPreferences.getBoolean("backlog", false)); if (!MainActivity.sharedPreferences.getBoolean("backlog", false)) view.findViewById(R.id.backlogStatus).setVisibility(View.GONE); else view.findViewById(R.id.backlogStatus).setVisibility(View.VISIBLE); }
From source file:io.github.tjg1.nori.ImageViewerActivity.java
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { if (requestCode == PERMISSION_REQUEST_DOWNLOAD_IMAGE && grantResults.length != 0) { if (grantResults[0] == PackageManager.PERMISSION_GRANTED && queuedDownloadRequestUrl != null) { getDownloadManager().enqueue(getImageDownloadRequest(queuedDownloadRequestUrl)); queuedDownloadRequestUrl = null; } else if (grantResults[0] == PackageManager.PERMISSION_DENIED) { Snackbar.make(findViewById(R.id.root), R.string.toast_imageDownloadPermissionDenied, Snackbar.LENGTH_LONG).show(); }/* ww w . ja v a 2 s.c o m*/ } }
From source file:nodomain.freeyourgadget.gadgetbridge.activities.ControlCenterv2.java
@TargetApi(Build.VERSION_CODES.M) private void checkAndRequestPermissions() { List<String> wantedPermissions = new ArrayList<>(); if (ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH) == PackageManager.PERMISSION_DENIED) wantedPermissions.add(Manifest.permission.BLUETOOTH); if (ContextCompat.checkSelfPermission(this, Manifest.permission.BLUETOOTH_ADMIN) == PackageManager.PERMISSION_DENIED) wantedPermissions.add(Manifest.permission.BLUETOOTH_ADMIN); if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CONTACTS) == PackageManager.PERMISSION_DENIED) wantedPermissions.add(Manifest.permission.READ_CONTACTS); if (ContextCompat.checkSelfPermission(this, Manifest.permission.CALL_PHONE) == PackageManager.PERMISSION_DENIED) wantedPermissions.add(Manifest.permission.CALL_PHONE); if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) == PackageManager.PERMISSION_DENIED) wantedPermissions.add(Manifest.permission.READ_PHONE_STATE); if (ContextCompat.checkSelfPermission(this, Manifest.permission.PROCESS_OUTGOING_CALLS) == PackageManager.PERMISSION_DENIED) wantedPermissions.add(Manifest.permission.PROCESS_OUTGOING_CALLS); if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_SMS) == PackageManager.PERMISSION_DENIED) wantedPermissions.add(Manifest.permission.READ_SMS); if (ContextCompat.checkSelfPermission(this, Manifest.permission.SEND_SMS) == PackageManager.PERMISSION_DENIED) wantedPermissions.add(Manifest.permission.SEND_SMS); if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_DENIED) wantedPermissions.add(Manifest.permission.READ_EXTERNAL_STORAGE); if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_CALENDAR) == PackageManager.PERMISSION_DENIED) wantedPermissions.add(Manifest.permission.READ_CALENDAR); if (!wantedPermissions.isEmpty()) ActivityCompat.requestPermissions(this, wantedPermissions.toArray(new String[wantedPermissions.size()]), 0);/*from w w w . ja v a2 s . c o m*/ }
From source file:com.concavenp.artistrymuse.ImageAppCompatActivity.java
@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode == RESULT_OK) { switch (requestCode) { case REQUEST_IMAGE_CAPTURE: { // Save off the values generated from the image creation setSpecificImageData(getType()); // If the user has the setting for making the files available outside this app then copy it // Get the sort type that should be used when requesting data from the movie DB SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); boolean scanMedia = prefs.getBoolean(getResources().getString(R.string.media_scanning_key), true); if (scanMedia) { File file = new File(mImagePath); // Tell the media scanner about the new file so that it is immediately available to the user. MediaScannerConnection.scanFile(this, new String[] { file.toString() }, null, new MediaScannerConnection.OnScanCompletedListener() { public void onScanCompleted(String path, Uri uri) { Log.i("ExternalStorage", "Scanned " + path + ":"); Log.i("ExternalStorage", "-> uri=" + uri); }/*from w ww . j a v a 2s . c o m*/ }); } // Load the captured image into the ImageView widget switch (getRectangleOrCircle(getType())) { case IMAGE_SHAPE_CIRCLE: { populateCircularImageView(mImagePath, getSpecificImageView(getType())); break; } case IMAGE_SHAPE_RECTANGLE: default: { populateThumbnailImageView(mImagePath, getSpecificImageView(getType())); break; } } break; } case REQUEST_IMAGE_STORE: { // Use the returned URI by passing it to the content resolver in order to get // access to he file chosen by the user. At this point copy the file locally // so it can be processed in the exact same fashion as the camera retrieved image. // The resulting URI of the user's image pick mSelectedImageUri = data.getData(); // We are about the retrieve files outside of this App's area. To do so, we // must have the right permission. Check to see if we do and then process the // image. If we do not, then request permission by presenting the user a // popup asking for permission. Since, we only bring this up when the user // hits the gallery I've decided to present the obvious reason why this App is // requesting permission. int permissionCheck = ContextCompat.checkSelfPermission(this, android.Manifest.permission.READ_EXTERNAL_STORAGE); if (permissionCheck == PackageManager.PERMISSION_DENIED) { ActivityCompat.requestPermissions(this, new String[] { android.Manifest.permission.READ_EXTERNAL_STORAGE }, REQUEST_PERMISSIONS_READ_EXTERNAL_STORAGE); // Continue processing in the callback associated with permissions (onRequestPermissionsResult) } else { // Copy the file locally and set the thumbnail and Save off the values generated from the image creation new ProcessExternalUriTask().execute(getSpecificImageView(getType())); } break; } } } }
From source file:com.jecelyin.editor.v2.ui.MainActivity.java
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { // Write external store permission requires a restart for (int i = 0; i < permissions.length; i++) { //Manifest.permission.WRITE_EXTERNAL_STORAGE.equals(permissions[i]) if (grantResults[i] == PackageManager.PERMISSION_DENIED) { requestWriteExternalStoragePermission(); return; }//from w w w.j av a 2s. c o m } start(); }
From source file:org.cloudsky.cordovaPlugins.BarcodeminCDV.java
/** * processes the result of permission request * * @param requestCode The code to get request action * @param permissions The collection of permissions * @param grantResults The result of grant *///from www. j a v a2 s . c om public void onRequestPermissionResult(int requestCode, String[] permissions, int[] grantResults) throws JSONException { PluginResult result; for (int r : grantResults) { if (r == PackageManager.PERMISSION_DENIED) { Log.d(LOG_TAG, "Permission Denied!"); result = new PluginResult(PluginResult.Status.ILLEGAL_ACCESS_EXCEPTION); this.callbackContext.sendPluginResult(result); return; } } switch (requestCode) { case 0: scan(this.requestArgs); break; } }
From source file:org.totschnig.myexpenses.activity.BackupRestoreActivity.java
@Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); switch (requestCode) { case ProtectionDelegate.PERMISSIONS_REQUEST_WRITE_CALENDAR: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_DENIED) { Toast.makeText(this, getString(R.string.calendar_permission_required), Toast.LENGTH_LONG).show(); ((DialogUtils.CalendarRestoreStrategyChangedListener) getSupportFragmentManager() .findFragmentByTag(FRAGMENT_TAG)).onCalendarPermissionDenied(); }/*from www. ja va2s .c o m*/ break; } }
From source file:com.microsoft.aad.adal.ReactNativeAdalPlugin.java
public void onRequestPermissionResult(int requestCode, String[] permissions, int[] grantResults) throws JSONException { for (int r : grantResults) { if (r == PackageManager.PERMISSION_DENIED) { this.permissionCallback.invoke(PERMISSION_DENIED_ERROR); return; }//from ww w . j a v a 2 s. c o m } this.permissionCallback.invoke(); }