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:com.vincent.shaka.util.EasyPermissions.java
/** * If user denied permissions with the flag NEVER ASK AGAIN, open a dialog explaining the * permissions rationale again and directing the user to the app settings. * * NOTE: use of this method is optional, should be called from * {@link PermissionCallbacks#onPermissionsDenied(int, List)} * * @param object the calling Activity or Fragment. * @param deniedPerms the set of denied permissions. * @return {@code true} if user denied at least one permission with the flag NEVER ASK AGAIN. *//*from ww w .j a va2 s . co m*/ public static boolean checkDeniedPermissionsNeverAskAgain(Object object, String rationale, @StringRes int positiveButton, @StringRes int negativeButton, List<String> deniedPerms) { boolean shouldShowRationale; for (String perm : deniedPerms) { shouldShowRationale = shouldShowRequestPermissionRationale(object, perm); if (!shouldShowRationale) { final Activity activity = getActivity(object); if (null == activity) { return true; } AlertDialog dialog = new AlertDialog.Builder(activity).setMessage(rationale) .setPositiveButton(positiveButton, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", activity.getPackageName(), null); intent.setData(uri); activity.startActivity(intent); } }).setNegativeButton(negativeButton, null).create(); dialog.show(); return true; } } return false; }
From source file:com.mobicage.rogerthat.plugins.messaging.widgets.PhotoUploadWidget.java
@Override public void initializeWidget() { mImagePreview = (ImageView) findViewById(R.id.image_preview); mSourceButton = (Button) findViewById(R.id.select_picture); mSourceButton.setText(R.string.get_picture); mPhotoSelected = false;//www .j a v a 2 s. co m mRatio = (String) mWidgetMap.get("ratio"); mQuality = (String) mWidgetMap.get("quality"); mSourceButton.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { final SafeRunnable runnableContinue = new SafeRunnable() { @Override protected void safeRun() throws Exception { getPicture(); } }; final SafeRunnable runnableCheckStorage = new SafeRunnable() { @Override protected void safeRun() throws Exception { if (mActivity.askPermissionIfNeeded(Manifest.permission.WRITE_EXTERNAL_STORAGE, ServiceMessageDetailActivity.PERMISSION_REQUEST_PHOTO_UPLOAD_WIDGET, runnableContinue, mActivity.showMandatoryPermissionPopup(mActivity, Manifest.permission.WRITE_EXTERNAL_STORAGE))) return; runnableContinue.run(); } }; if (TRUE.equals(mWidgetMap.get("camera"))) { if (mActivity.askPermissionIfNeeded(Manifest.permission.CAMERA, ServiceMessageDetailActivity.PERMISSION_REQUEST_PHOTO_UPLOAD_WIDGET, runnableCheckStorage, mActivity.showMandatoryPermissionPopup(mActivity, Manifest.permission.CAMERA))) return; } runnableCheckStorage.run(); } private void getPicture() { File image; try { image = getTmpUploadPhotoLocation(); } catch (IOException e) { L.d(e.getMessage()); UIUtils.showLongToast(getContext(), e.getMessage()); return; } mUriSavedImage = Uri.fromFile(image); Intent cameraIntent = null; boolean hasCamera = mActivity.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA); boolean hasCameraPermission = mActivity.getMainService().isPermitted(Manifest.permission.CAMERA); if (hasCamera && hasCameraPermission) { cameraIntent = ActivityUtils.buildTakePictureIntent(mActivity, mUriSavedImage, Facing.BACK); } Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); galleryIntent.putExtra(MediaStore.EXTRA_OUTPUT, mUriSavedImage); galleryIntent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString()); galleryIntent.setType("image/*"); final Intent chooserIntent; if (TRUE.equals(mWidgetMap.get("gallery")) && TRUE.equals(mWidgetMap.get("camera"))) { chooserIntent = Intent.createChooser(galleryIntent, mActivity.getString(R.string.select_source)); if (cameraIntent != null) { chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { cameraIntent }); } mActivity.startActivityForResult(chooserIntent, PICK_IMAGE); } else if (TRUE.equals(mWidgetMap.get("gallery"))) { chooserIntent = Intent.createChooser(galleryIntent, mActivity.getString(R.string.select_source)); mActivity.startActivityForResult(chooserIntent, PICK_IMAGE); } else if (TRUE.equals(mWidgetMap.get("camera"))) { if (cameraIntent != null) { mActivity.startActivityForResult(cameraIntent, PICK_IMAGE); } else if (!hasCamera) { UIUtils.showDialog(mActivity, R.string.no_camera_available_title, R.string.no_camera_available); } else if (!hasCameraPermission) { String title = mActivity.getString(R.string.need_camera_permission_title); String message = mActivity.getString(R.string.need_camera_permission); SafeDialogClick onPositiveClick = new SafeDialogClick() { @Override public void safeOnClick(DialogInterface dialog, int id) { dialog.dismiss(); Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", mActivity.getPackageName(), null); intent.setData(uri); mActivity.startActivity(intent); } }; UIUtils.showDialog(mActivity, title, message, R.string.go_to_app_settings, onPositiveClick, R.string.cancel, null); } } } }); }
From source file:cn.motalks.mtdc.utils.EasyPermissionsEx.java
/** * * prompt the user to go to the app's settings screen and enable permissions. If the * user clicks snackbar's action, they are sent to the settings screen. The result is returned * to the Activity via {@link Activity#onActivityResult(int, int, Intent)}. * * @param object Activity or Fragment requesting permissions. * @param rationale a message explaining why the application needs this set of permissions, will * be displayed on the snackbar. * @param snackbarAction text disPlayed on the snackbar's action * @param requestCode If >= 0, this code will be returned in onActivityResult() when the activity exits. *///www. j av a 2 s .c o m public static void goSettings2Permissions(final Object object, String rationale, String snackbarAction, final int requestCode) { checkCallingObjectSuitability(object); final Activity activity = getActivity(object); if (null == activity) { return; } Snackbar.make(activity.findViewById(android.R.id.content), rationale, Snackbar.LENGTH_LONG) .setAction(snackbarAction, new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", activity.getPackageName(), null); intent.setData(uri); startForResult(object, intent, requestCode); } }).show(); }
From source file:com.fisher.wxtrend.permission.EasyPermission.java
/** * OnActivityResult???//from w ww . j a v a2 s . c om * {@link EasyPermission#hasPermissions(Context, String...)} * * If user denied permissions with the flag NEVER ASK AGAIN, open a dialog explaining the * permissions rationale again and directing the user to the app settings. After the user * returned to the app, {@link Activity#onActivityResult(int, int, Intent)} or * {@link Fragment#onActivityResult(int, int, Intent)} or * {@link android.app.Fragment#onActivityResult(int, int, Intent)} will be called with * {@value #SETTINGS_REQ_CODE} as requestCode * <p> * * NOTE: use of this method is optional, should be called from * {@link PermissionCallback#onPermissionDenied(int, List)} * * @return {@code true} if user denied at least one permission with the flag NEVER ASK AGAIN. */ public static boolean checkDeniedPermissionsNeverAskAgain(final Object object, String rationale, @StringRes int positiveButton, @StringRes int negativeButton, @Nullable DialogInterface.OnClickListener negativeButtonOnClickListener, List<String> deniedPerms) { boolean shouldShowRationale; for (String perm : deniedPerms) { shouldShowRationale = PermissionUtils.shouldShowRequestPermissionRationale(object, perm); if (!shouldShowRationale) { final Activity activity = PermissionUtils.getActivity(object); if (null == activity) { return true; } new AlertDialog.Builder(activity).setMessage(rationale) .setPositiveButton(positiveButton, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", activity.getPackageName(), null); intent.setData(uri); startAppSettingsScreen(object, intent); } }).setNegativeButton(negativeButton, negativeButtonOnClickListener).create().show(); return true; } } return false; }
From source file:com.tml.sharethem.receiver.ReceiverActivity.java
@Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { super.onRequestPermissionsResult(requestCode, permissions, grantResults); switch (requestCode) { case PERMISSIONS_REQUEST_CODE_ACCESS_COARSE_LOCATION: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { if (checkLocationAccess()) startSenderScan();/*from w w w .j ava 2 s . co m*/ } else { if (ActivityCompat.shouldShowRequestPermissionRationale(this, Manifest.permission.ACCESS_COARSE_LOCATION)) { showOptionsDialogWithListners(getString(R.string.p2p_receiver_gps_permission_warning), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { checkLocationPermission(); } }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }, "Re-Try", "Yes, Im Sure"); } else { showOptionsDialogWithListners(getString(R.string.p2p_receiver_gps_no_permission_prompt), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { try { Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", getPackageName(), null); intent.setData(uri); startActivity(intent); } catch (ActivityNotFoundException anf) { Toast.makeText(getApplicationContext(), "Settings activity not found", Toast.LENGTH_SHORT).show(); } } }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { finish(); } }, getString(R.string.label_settings), getString(R.string.Action_cancel)); } } } }
From source file:co.lemonlabs.android.slidingdebugmenu.SlidingDebugMenu.java
@SuppressWarnings("ConstantConditions") @Override/*from www . j ava2 s . c o m*/ public void onClick(View v) { final int id = v.getId(); Context context = getContext(); if (id == R.id.sdm__settings_developer) { // open dev settings Intent devIntent = new Intent(Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS); ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(devIntent, 0); if (resolveInfo != null) context.startActivity(devIntent); else Toast.makeText(context, "Developer settings not available on device", Toast.LENGTH_SHORT).show(); } else if (id == R.id.sdm__settings_battery) { // try to find an app to handle battery settings Intent batteryIntent = new Intent(Intent.ACTION_POWER_USAGE_SUMMARY); ResolveInfo resolveInfo = context.getPackageManager().resolveActivity(batteryIntent, 0); if (resolveInfo != null) context.startActivity(batteryIntent); else Toast.makeText(context, "No app found to handle power usage intent", Toast.LENGTH_SHORT).show(); } else if (id == R.id.sdm__settings_drawer) { // open android settings context.startActivity(new Intent(Settings.ACTION_SETTINGS)); } else if (id == R.id.sdm__settings_app_info) { Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); intent.setData(Uri.parse("package:" + context.getPackageName())); context.startActivity(intent); } else if (id == R.id.sdm__settings_uninstall) { // open dialog to uninstall app Uri packageURI = Uri.parse("package:" + context.getPackageName()); Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI); context.startActivity(uninstallIntent); } }
From source file:com.garyhu.citypickerdemo.widget.permission.easyPermission.EasyPermission.java
/** * OnActivityResult???//from w ww. j av a 2 s . c o m * {@link EasyPermission#hasPermissions(Context, String...)} * * If user denied permissions with the flag NEVER ASK AGAIN, open a dialog explaining the * permissions rationale again and directing the user to the app settings. After the user * returned to the app, {@link Activity#onActivityResult(int, int, Intent)} or * {@link Fragment#onActivityResult(int, int, Intent)} or * {@link android.app.Fragment#onActivityResult(int, int, Intent)} will be called with * {@value #SETTINGS_REQ_CODE} as requestCode * <p> * * NOTE: use of this method is optional, should be called from * {@link PermissionCallback#onEasyPermissionDenied(int, String[])} * * @return {@code true} if user denied at least one permission with the flag NEVER ASK AGAIN. */ public static boolean checkDeniedPermissionsNeverAskAgain(final Object object, String rationale, @StringRes int positiveButton, @StringRes int negativeButton, @Nullable DialogInterface.OnClickListener negativeButtonOnClickListener, String... deniedPerms) { boolean shouldShowRationale; for (String perm : deniedPerms) { shouldShowRationale = Utils.shouldShowRequestPermissionRationale(object, perm); if (!shouldShowRationale) { final Activity activity = Utils.getActivity(object); if (null == activity) { return true; } new AlertDialog.Builder(activity).setMessage(rationale) .setPositiveButton(positiveButton, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", activity.getPackageName(), null); intent.setData(uri); startAppSettingsScreen(object, intent); } }).setNegativeButton(negativeButton, negativeButtonOnClickListener).create().show(); return true; } } return false; }
From source file:com.sean.nanastudio.taoyuanstreetparking.MainActivity.java
public static void startInstalledAppDetailsActivity(final Activity context) { if (context == null) { return;/*from w w w . j a v a 2s . c om*/ } final Intent i = new Intent(); i.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); i.addCategory(Intent.CATEGORY_DEFAULT); i.setData(Uri.parse("package:" + context.getPackageName())); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); context.startActivity(i); }
From source file:com.google.android.apps.muzei.gallery.GallerySettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gallery_activity); Toolbar appBar = (Toolbar) findViewById(R.id.app_bar); setSupportActionBar(appBar);/*from w w w . j a va 2 s . c o m*/ getSupportLoaderManager().initLoader(0, null, this); bindService(new Intent(this, GalleryArtSource.class).setAction(GalleryArtSource.ACTION_BIND_GALLERY), mServiceConnection, BIND_AUTO_CREATE); mPlaceholderDrawable = new ColorDrawable( ContextCompat.getColor(this, R.color.gallery_chosen_photo_placeholder)); mPhotoGridView = (RecyclerView) findViewById(R.id.photo_grid); DefaultItemAnimator itemAnimator = new DefaultItemAnimator(); itemAnimator.setSupportsChangeAnimations(false); mPhotoGridView.setItemAnimator(itemAnimator); setupMultiSelect(); final GridLayoutManager gridLayoutManager = new GridLayoutManager(GallerySettingsActivity.this, 1); mPhotoGridView.setLayoutManager(gridLayoutManager); final ViewTreeObserver vto = mPhotoGridView.getViewTreeObserver(); vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { int width = mPhotoGridView.getWidth() - mPhotoGridView.getPaddingStart() - mPhotoGridView.getPaddingEnd(); if (width <= 0) { return; } // Compute number of columns int maxItemWidth = getResources() .getDimensionPixelSize(R.dimen.gallery_chosen_photo_grid_max_item_size); int numColumns = 1; while (true) { if (width / numColumns > maxItemWidth) { ++numColumns; } else { break; } } int spacing = getResources().getDimensionPixelSize(R.dimen.gallery_chosen_photo_grid_spacing); mItemSize = (width - spacing * (numColumns - 1)) / numColumns; // Complete setup gridLayoutManager.setSpanCount(numColumns); mChosenPhotosAdapter.setHasStableIds(true); mPhotoGridView.setAdapter(mChosenPhotosAdapter); mPhotoGridView.getViewTreeObserver().removeOnGlobalLayoutListener(this); tryUpdateSelection(false); } }); ViewCompat.setOnApplyWindowInsetsListener(mPhotoGridView, new OnApplyWindowInsetsListener() { @Override public WindowInsetsCompat onApplyWindowInsets(final View v, final WindowInsetsCompat insets) { int gridSpacing = getResources().getDimensionPixelSize(R.dimen.gallery_chosen_photo_grid_spacing); ViewCompat.onApplyWindowInsets(v, insets.replaceSystemWindowInsets(insets.getSystemWindowInsetLeft() + gridSpacing, gridSpacing, insets.getSystemWindowInsetRight() + gridSpacing, insets.getSystemWindowInsetBottom() + insets.getSystemWindowInsetTop() + gridSpacing + getResources().getDimensionPixelSize(R.dimen.gallery_fab_space))); return insets; } }); Button enableRandomImages = (Button) findViewById(R.id.gallery_enable_random); enableRandomImages.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { ActivityCompat.requestPermissions(GallerySettingsActivity.this, new String[] { Manifest.permission.READ_EXTERNAL_STORAGE }, REQUEST_STORAGE_PERMISSION); } }); Button permissionSettings = (Button) findViewById(R.id.gallery_edit_permission_settings); permissionSettings.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View view) { Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS, Uri.fromParts("package", getPackageName(), null)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); } }); mAddButton = findViewById(R.id.add_photos_button); mAddButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Use ACTION_OPEN_DOCUMENT by default for adding photos. // This allows us to use persistent URI permissions to access the underlying photos // meaning we don't need to use additional storage space and will pull in edits automatically // in addition to syncing deletions. // (There's a separate 'Import photos' option which uses ACTION_GET_CONTENT to support legacy apps) Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.setType("image/*"); intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true); startActivityForResult(intent, REQUEST_CHOOSE_PHOTOS); } }); }
From source file:com.tomclaw.appteka.main.view.AppsView.java
private void showActionDialog(final AppItem appItem) { ListAdapter menuAdapter = new MenuAdapter(getContext(), R.array.app_actions_titles, R.array.app_actions_icons);/*ww w.j a v a2 s . c o m*/ new AlertDialog.Builder(getContext()).setAdapter(menuAdapter, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: { FlurryAgent.logEvent("App menu: run"); PackageManager packageManager = getContext().getPackageManager(); Intent launchIntent = packageManager.getLaunchIntentForPackage(appItem.getPackageName()); if (launchIntent == null) { Snackbar.make(recyclerView, R.string.non_launchable_package, Snackbar.LENGTH_LONG).show(); } else { startActivity(launchIntent); } break; } case 1: { FlurryAgent.logEvent("App menu: share"); TaskExecutor.getInstance() .execute(new ExportApkTask(getContext(), appItem, ExportApkTask.ACTION_SHARE)); break; } case 2: { FlurryAgent.logEvent("App menu: extract"); TaskExecutor.getInstance() .execute(new ExportApkTask(getContext(), appItem, ExportApkTask.ACTION_EXTRACT)); break; } case 3: { FlurryAgent.logEvent("App menu: upload"); Intent intent = new Intent(getContext(), UploadActivity.class); intent.putExtra(UploadActivity.UPLOAD_ITEM, appItem); startActivity(intent); break; } case 4: { FlurryAgent.logEvent("App menu: bluetooth"); TaskExecutor.getInstance() .execute(new ExportApkTask(getContext(), appItem, ExportApkTask.ACTION_BLUETOOTH)); break; } case 5: { FlurryAgent.logEvent("App menu: Google Play"); String packageName = appItem.getPackageName(); openGooglePlay(getContext(), packageName); break; } case 6: { FlurryAgent.logEvent("App menu: permissions"); try { PackageInfo packageInfo = appItem.getPackageInfo(); List<String> permissions = Arrays.asList(packageInfo.requestedPermissions); Intent intent = new Intent(getContext(), PermissionsActivity.class).putStringArrayListExtra( PermissionsActivity.EXTRA_PERMISSIONS, new ArrayList<>(permissions)); startActivity(intent); } catch (Throwable ex) { Snackbar.make(recyclerView, R.string.unable_to_get_permissions, Snackbar.LENGTH_LONG) .show(); } break; } case 7: { FlurryAgent.logEvent("App menu: details"); setRefreshOnResume(); final Intent intent = new Intent().setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS) .addCategory(Intent.CATEGORY_DEFAULT) .setData(Uri.parse("package:" + appItem.getPackageName())) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); break; } case 8: { FlurryAgent.logEvent("App menu: remove"); setRefreshOnResume(); Uri packageUri = Uri.parse("package:" + appItem.getPackageName()); Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageUri); startActivity(uninstallIntent); break; } } } }).show(); }