List of usage examples for android.provider Settings ACTION_APPLICATION_DETAILS_SETTINGS
String ACTION_APPLICATION_DETAILS_SETTINGS
To view the source code for android.provider Settings ACTION_APPLICATION_DETAILS_SETTINGS.
Click Source Link
From source file:ac.robinson.bettertogether.ConnectionSetupActivity.java
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String permissions[], @NonNull int[] grantResults) { switch (requestCode) { case CAMERA_PERMISSION_RESULT: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { restartCaptureManager();/* ww w.j a v a 2 s .c o m*/ } else { AlertDialog.Builder builder = new AlertDialog.Builder(ConnectionSetupActivity.this); builder.setTitle(R.string.title_camera_access); builder.setMessage(R.string.hint_enable_camera_access); builder.setPositiveButton(R.string.hint_edit_permissions, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setData( Uri.fromParts("package", ConnectionSetupActivity.this.getPackageName(), null)); try { startActivity(intent); } catch (ActivityNotFoundException e) { // we've tried everything by this point! Log.d(TAG, "Camera permission denied and request failed - will not be able to scan codes"); Toast.makeText(ConnectionSetupActivity.this, R.string.error_accessing_camera, Toast.LENGTH_LONG).show(); } restartCaptureManager(); } }); builder.setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(ConnectionSetupActivity.this, R.string.error_accessing_location, Toast.LENGTH_LONG).show(); restartCaptureManager(); // reset capture UI and try again } }); builder.show(); } break; case COARSE_LOCATION_PERMISSION_RESULT: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { createClient(); } else { AlertDialog.Builder builder = new AlertDialog.Builder(ConnectionSetupActivity.this); builder.setTitle(R.string.title_coarse_location_access); builder.setMessage(R.string.hint_enable_coarse_location_access); builder.setPositiveButton(R.string.hint_edit_permissions, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setData( Uri.fromParts("package", ConnectionSetupActivity.this.getPackageName(), null)); try { startActivity(intent); } catch (ActivityNotFoundException e) { // we've tried everything by this point! Log.d(TAG, "Coarse location permission denied and request failed - will not be able to connect"); Toast.makeText(ConnectionSetupActivity.this, R.string.error_accessing_location, Toast.LENGTH_LONG).show(); } restartCaptureManager(); } }); builder.setNegativeButton(R.string.button_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(ConnectionSetupActivity.this, R.string.error_accessing_location, Toast.LENGTH_LONG).show(); restartCaptureManager(); // reset capture UI and try again } }); builder.show(); } break; default: if (mCaptureManager != null && requestCode == CaptureManager.getCameraPermissionReqCode()) { // ignored - CaptureManager's default is to exit on permission denial, so we handle permissions ourselves // mCaptureManager.onRequestPermissionsResult(requestCode, permissions, grantResults); } break; } }
From source file:net.nym.napply.library.common.NBasePermissionActivity.java
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { if (verifyPermissions(grantResults)) { switch (requestCode) { case REQUEST_CAMERA: // Camera permission has been granted, preview can be displayed showCamera();//from w ww . ja v a 2 s .co m break; case REQUEST_CONTACTS: showContacts(); break; case REQUEST_CALENDAR: showCalendar(); break; case REQUEST_LOCATION: showLocation(); break; case REQUEST_STORAGE: showStorage(); break; case REQUEST_MICROPHONE: showMicrophone(); break; case REQUEST_SENSORS: showSensors(); break; case REQUEST_PHONE: showPhone(); break; case REQUEST_SMS: showSms(); break; case REQUEST_CAMERA_AND_STORAGE: showCameraAndStorage(); break; default: super.onRequestPermissionsResult(requestCode, permissions, grantResults); break; } } else { // Log.i(TAG, "CAMERA permission was NOT granted."); Log.i("???%s", Arrays.toString(permissions)); String permission = ""; switch (requestCode) { case REQUEST_CAMERA: permission = "?"; break; case REQUEST_CONTACTS: permission = ""; break; case REQUEST_CALENDAR: permission = ""; break; case REQUEST_LOCATION: permission = "??"; break; case REQUEST_STORAGE: permission = ""; break; case REQUEST_MICROPHONE: permission = ""; break; case REQUEST_SENSORS: permission = ""; break; case REQUEST_PHONE: permission = "?"; break; case REQUEST_SMS: permission = ""; break; case REQUEST_CAMERA_AND_STORAGE: permission = "?"; break; default: super.onRequestPermissionsResult(requestCode, permissions, grantResults); break; } final Dialog dialog = new AlertDialog.Builder(this).setTitle(R.string.napply_hint) .setMessage(String.format("?%s", permission)) .setNegativeButton(R.string.napply_cancel, null) .setPositiveButton(R.string.napply_toSet, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", getApplicationInfo().packageName, null); intent.setData(uri); startActivity(intent); } }).create(); dialog.show(); } }
From source file:com.hmatalonga.greenhub.ui.TaskListActivity.java
private void checkIfLastAppIsKilled() { if (mLastKilledApp != null && isKilledAppAlive(mLastKilledApp.getLabel())) { final String packageName = mLastKilledApp.getPackageInfo().packageName; AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(getString(R.string.kill_app_dialog_text)).setTitle(mLastKilledApp.getLabel()); builder.setPositiveButton(R.string.force_close, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User clicked OK button startActivity(new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:" + packageName))); }//from w w w. j a v a2 s .c o m }); builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // User cancelled the dialog dialog.cancel(); } }); builder.create().show(); } mLastKilledApp = null; }
From source file:com.barbrdo.app.activities.SignUpActivity.java
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { Log.i(TAG, "onRequestPermissionResult"); if (requestCode == REQUEST_PERMISSIONS_REQUEST_CODE) { if (grantResults.length <= 0) { Log.i(TAG, "User interaction was cancelled."); } else if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { if (mRequestingLocationUpdates) { Log.i(TAG, "Permission granted, updates requested, starting location updates"); startLocationUpdates();/*from www.ja va2s . c o m*/ } } else { showSnackBar(R.string.permission_denied_explanation, R.string.settings, new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", BuildConfig.APPLICATION_ID, null); intent.setData(uri); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }); return; } } }
From source file:com.chhavi.envisionproductivity.FitnessActivity.java
/** * Callback received when a permissions request has been completed. *//*from w w w . j a v a2s.co m*/ @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { Log.i(TAG, "onRequestPermissionResult"); if (requestCode == REQUEST_PERMISSIONS_REQUEST_CODE) { if (grantResults.length <= 0) { // If user interaction was interrupted, the permission request is cancelled and you // receive empty arrays. Log.i(TAG, "User interaction was cancelled."); } else if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { // Permission was granted. buildFitnessClient(); } else { // Permission denied. // In this Activity we've chosen to notify the user that they // have rejected a core permission for the app since it makes the Activity useless. // We're communicating this message in a Snackbar since this is a sample app, but // core permissions would typically be best requested during a welcome-screen flow. // Additionally, it is important to remember that a permission might have been // rejected without asking the user for permission (device policy or "Never ask // again" prompts). Therefore, a user interface affordance is typically implemented // when permissions are denied. Otherwise, your app could appear unresponsive to // touches or interactions which have required permissions. Snackbar.make(findViewById(R.id.main_activity_view), "Permission denied", Snackbar.LENGTH_LONG) .setAction("Settings", new View.OnClickListener() { @Override public void onClick(View view) { // Build intent that displays the App settings screen. Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", BuildConfig.APPLICATION_ID, null); intent.setData(uri); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }).show(); } } }
From source file:com.tenforwardconsulting.cordova.BackgroundGeolocationPlugin.java
public void showAppSettings() { Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.addCategory(Intent.CATEGORY_DEFAULT); intent.setData(Uri.parse("package:" + getContext().getPackageName())); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); getContext().startActivity(intent);/*w w w.ja va2s .c o m*/ }
From source file:com.example.sensorsample.MyActivity.java
/** * Callback received when a permissions request has been completed. *//* w w w .j a va 2s. c o m*/ @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { Log.i(TAG, "onRequestPermissionResult"); if (requestCode == REQUEST_PERMISSIONS_REQUEST_CODE) { if (grantResults.length <= 0) { // If user interaction was interrupted, the permission request is cancelled and you // receive empty arrays. Log.i(TAG, "User interaction was cancelled."); } else if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { // Permission was granted. buildApiClient(); } else { // Permission denied. // In this Activity we've chosen to notify the user that they // have rejected a core permission for the app since it makes the Activity useless. // We're communicating this message in a Snackbar since this is a sample app, but // core permissions would typically be best requested during a welcome-screen flow. // Additionally, it is important to remember that a permission might have been // rejected without asking the user for permission (device policy or "Never ask // again" prompts). Therefore, a user interface affordance is typically implemented // when permissions are denied. Otherwise, your app could appear unresponsive to // touches or interactions which have required permissions. Snackbar.make(findViewById(R.id.main_activity_view), R.string.permission_denied_explanation, Snackbar.LENGTH_INDEFINITE).setAction(R.string.settings, new View.OnClickListener() { @Override public void onClick(View view) { // Build intent that displays the App settings screen. Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", BuildConfig.APPLICATION_ID, null); intent.setData(uri); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }).show(); } } }
From source file:com.bridgeconn.autographago.ui.activities.SettingsActivity.java
@Override public void onRequestPermissionsResult(final int requestCode, String[] permissions, int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); switch (requestCode) { case Constants.RequestCodes.PERMISSION_STORAGE: { if (ContextCompat.checkSelfPermission(SettingsActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED) { startDownload(downloadUrl);// w w w. j av a 2 s . com } else { String positiveButton; if (!shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) { positiveButton = getString(R.string.take_me_to_settings).toUpperCase(); } else { positiveButton = getString(R.string.try_again).toUpperCase(); } AlertDialog.Builder builder = new AlertDialog.Builder(SettingsActivity.this, R.style.DialogThemeLight); builder.setMessage(getString(R.string.storage_permission_message)); builder.setPositiveButton(positiveButton, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); if (!shouldShowRequestPermissionRationale(Manifest.permission.WRITE_EXTERNAL_STORAGE)) { Intent myAppSettings = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.parse("package:" + SettingsActivity.this.getPackageName())); myAppSettings.addCategory(Intent.CATEGORY_DEFAULT); startActivityForResult(myAppSettings, Constants.RequestCodes.APP_SETTINGS_STORAGE); } else { ActivityCompat.requestPermissions(SettingsActivity.this, new String[] { Manifest.permission.WRITE_EXTERNAL_STORAGE }, requestCode); } } }); builder.setNegativeButton(getString(R.string.cancel).toUpperCase(), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.show(); } break; } } }
From source file:com.google.android.gms.fit.samples.basichistorysessions.MainActivity.java
/** * Callback received when a permissions request has been completed. *//*from ww w.j a va 2s. c o m*/ @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { Log.i(TAG, "onRequestPermissionResult"); if (requestCode == REQUEST_PERMISSIONS_REQUEST_CODE) { if (grantResults.length <= 0) { // If user interaction was interrupted, the permission request is cancelled and you // receive empty arrays. Log.i(TAG, "User interaction was cancelled."); } else if (grantResults[0] == PackageManager.PERMISSION_GRANTED) { // Permission was granted. buildFitnessClient(); } else { // Permission denied. // In this Activity we've chosen to notify the user that they // have rejected a core permission for the app since it makes the Activity useless. // We're communicating this message in a Snackbar since this is a sample app, but // core permissions would typically be best requested during a welcome-screen flow. // Additionally, it is important to remember that a permission might have been // rejected without asking the user for permission (device policy or "Never ask // again" prompts). Therefore, a user interface affordance is typically implemented // when permissions are denied. Otherwise, your app could appear unresponsive to // touches or interactions which have required permissions. Snackbar.make(findViewById(R.id.main_activity_view), R.string.permission_denied_explanation, Snackbar.LENGTH_INDEFINITE).setAction(R.string.settings, new View.OnClickListener() { @Override public void onClick(View view) { // Build intent that displays the App settings screen. Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", BuildConfig.APPLICATION_ID, null); intent.setData(uri); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }).show(); } } }
From source file:com.google.android.apps.muzei.settings.ChooseSourceFragment.java
private void redrawSources() { if (mSourceContainerView == null || !isAdded()) { return;//from www. j av a 2 s . c o m } mSourceContainerView.removeAllViews(); for (final Source source : mSources) { source.rootView = LayoutInflater.from(getContext()).inflate(R.layout.settings_choose_source_item, mSourceContainerView, false); source.selectSourceButton = source.rootView.findViewById(R.id.source_image); source.selectSourceButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (source.componentName.equals(mSelectedSource)) { if (getContext() instanceof Callbacks) { ((Callbacks) getContext()).onRequestCloseActivity(); } else if (getParentFragment() instanceof Callbacks) { ((Callbacks) getParentFragment()).onRequestCloseActivity(); } } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && source.targetSdkVersion >= Build.VERSION_CODES.O) { AlertDialog.Builder builder = new AlertDialog.Builder(getContext()) .setTitle(R.string.action_source_target_too_high_title) .setMessage(R.string.action_source_target_too_high_message) .setNegativeButton(R.string.action_source_target_too_high_learn_more, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse( "https://medium.com/@ianhlake/the-muzei-plugin-api-and-androids-evolution-9b9979265cfb"))); } }) .setPositiveButton(R.string.action_source_target_too_high_dismiss, null); final Intent sendFeedbackIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://play.google.com/store/apps/details?id=" + source.componentName.getPackageName())); if (sendFeedbackIntent.resolveActivity(getContext().getPackageManager()) != null) { builder.setNeutralButton( getString(R.string.action_source_target_too_high_send_feedback, source.label), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { startActivity(sendFeedbackIntent); } }); } builder.show(); } else if (source.setupActivity != null) { Bundle bundle = new Bundle(); bundle.putString(FirebaseAnalytics.Param.ITEM_ID, source.componentName.flattenToShortString()); bundle.putString(FirebaseAnalytics.Param.ITEM_NAME, source.label); bundle.putString(FirebaseAnalytics.Param.ITEM_CATEGORY, "sources"); FirebaseAnalytics.getInstance(getContext()).logEvent(FirebaseAnalytics.Event.VIEW_ITEM, bundle); mCurrentInitialSetupSource = source.componentName; launchSourceSetup(source); } else { Bundle bundle = new Bundle(); bundle.putString(FirebaseAnalytics.Param.ITEM_ID, source.componentName.flattenToShortString()); bundle.putString(FirebaseAnalytics.Param.CONTENT_TYPE, "sources"); FirebaseAnalytics.getInstance(getContext()).logEvent(FirebaseAnalytics.Event.SELECT_CONTENT, bundle); SourceManager.selectSource(getContext(), source.componentName); } } }); source.selectSourceButton.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { final String pkg = source.componentName.getPackageName(); if (TextUtils.equals(pkg, getContext().getPackageName())) { // Don't open Muzei's app info return false; } // Otherwise open third party extensions try { startActivity(new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", pkg, null))); } catch (final ActivityNotFoundException e) { return false; } return true; } }); float alpha = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && source.targetSdkVersion >= Build.VERSION_CODES.O ? ALPHA_DISABLED : ALPHA_UNSELECTED; source.rootView.setAlpha(alpha); source.icon.setColorFilter(source.color, PorterDuff.Mode.SRC_ATOP); source.selectSourceButton.setBackground(source.icon); TextView titleView = source.rootView.findViewById(R.id.source_title); titleView.setText(source.label); titleView.setTextColor(source.color); updateSourceStatusUi(source); source.settingsButton = source.rootView.findViewById(R.id.source_settings_button); TooltipCompat.setTooltipText(source.settingsButton, source.settingsButton.getContentDescription()); source.settingsButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { launchSourceSettings(source); } }); animateSettingsButton(source.settingsButton, false, false); mSourceContainerView.addView(source.rootView); } updateSelectedItem(mCurrentSourceLiveData.getValue(), false); }