List of usage examples for android.net Uri fromParts
public static Uri fromParts(String scheme, String ssp, String fragment)
From source file:pub.devrel.easypermissions.EasyPermission.java
/** * OnActivityResult???/* w ww .ja v a2 s . com*/ * {@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 = 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.felkertech.n.ActivityUtils.java
public static void writeDriveData(final Activity context, GoogleApiClient gapi) { //Ask here for permission to storage PermissionUtils.requestPermissionIfDisabled(context, android.Manifest.permission.WRITE_EXTERNAL_STORAGE, context.getString(R.string.permission_storage_rationale)); if (PermissionUtils.isDisabled(context, android.Manifest.permission_group.STORAGE)) { new MaterialDialog.Builder(context).title(R.string.permission_not_allowed_error) .content(R.string.permission_not_allowed_text).positiveText(R.string.permission_action_settings) .negativeText(R.string.ok).callback(new MaterialDialog.ButtonCallback() { @Override//from ww w .j ava2 s . c om public void onPositive(MaterialDialog dialog) { super.onPositive(dialog); Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", context.getPackageName(), null); intent.setData(uri); } }).build(); } else actuallyWriteData(context, gapi); }
From source file:io.github.marktony.espresso.mvp.addpackage.AddPackageFragment.java
/** * To handle the permission grant result. * If the user denied the permission, show a dialog to explain * the reason why the app need such permission and lead he/her * to the system settings to grant permission. * @param requestCode The request code. See at {@link AddPackageFragment#REQUEST_CAMERA_PERMISSION_CODE} * @param permissions The wanted permissions. * @param grantResults The results.//from w ww . jav a 2 s . c o m */ @Override public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { switch (requestCode) { case REQUEST_CAMERA_PERMISSION_CODE: if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { startScanningActivity(); } else { hideImm(); AlertDialog dialog = new AlertDialog.Builder(getContext()).setTitle(R.string.permission_denied) .setMessage(R.string.require_permission) .setPositiveButton(R.string.go_to_settings, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // Go to the detail settings of our application Intent intent = new Intent(); intent.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); Uri uri = Uri.fromParts("package", getContext().getPackageName(), null); intent.setData(uri); startActivity(intent); dialog.dismiss(); } }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }).create(); dialog.show(); } break; default: } }
From source file:com.hundsun.yr.mobile.lib.permission.PermissionManager.java
/** * OnActivityResult???// ww w. ja v a2 s. co m * {@link PermissionManager#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 = 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.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. jav a 2s. c o 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;//from w w w . java 2 s .c om 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. *//* w w w. 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.filemanager.free.fragments.preference_fragments.Preffrag.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); PreferenceUtils.reset();//w ww .jav a 2 s . c o m // Load the preferences from an XML resource addPreferencesFromResource(R.xml.preferences); preferences = (com.filemanager.free.activities.Preferences) getActivity(); sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity()); final int th1 = Integer.parseInt(sharedPref.getString("theme", "0")); theme = th1 == 2 ? PreferenceUtils.hourOfDay() : th1; /*findPreference("donate").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { ((com.filemanager.free.activities.Preferences) getActivity()).donate(); return false; } });*/ findPreference("columns").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { final String[] sort = getResources().getStringArray(R.array.columns); MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity()); if (theme == 1) a.theme(Theme.DARK); a.title(R.string.gridcolumnno); int current = Integer.parseInt(sharedPref.getString("columns", "-1")); current = current == -1 ? 0 : current; if (current != 0) current = current - 1; a.items(sort).itemsCallbackSingleChoice(current, new MaterialDialog.ListCallbackSingleChoice() { @Override public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { sharedPref.edit().putString("columns", "" + (which != 0 ? sort[which] : "" + -1)).commit(); dialog.dismiss(); return true; } }); a.build().show(); return true; } }); findPreference("theme").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { String[] sort = getResources().getStringArray(R.array.theme); int current = Integer.parseInt(sharedPref.getString("theme", "0")); MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity()); if (theme == 1) a.theme(Theme.DARK); a.items(sort).itemsCallbackSingleChoice(current, new MaterialDialog.ListCallbackSingleChoice() { @Override public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { sharedPref.edit().putString("theme", "" + which).commit(); dialog.dismiss(); restartPC(getActivity()); return true; } }); a.title(R.string.theme); a.build().show(); return true; } }); final SwitchPreference rootmode = (SwitchPreference) findPreference("rootmode"); rootmode.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { boolean b = sharedPref.getBoolean("rootmode", false); if (b) { if (RootTools.isAccessGiven()) { rootmode.setChecked(true); } else { rootmode.setChecked(false); Toast.makeText(getActivity(), getResources().getString(R.string.rootfailure), Toast.LENGTH_LONG).show(); } } else { rootmode.setChecked(false); } return false; } }); //Directory sort mode findPreference("dirontop").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { String[] sort = getResources().getStringArray(R.array.directorysortmode); MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity()); if (theme == 1) a.theme(Theme.DARK); a.title(R.string.directorysort); int current = Integer.parseInt(sharedPref.getString("dirontop", "0")); a.items(sort).itemsCallbackSingleChoice(current, new MaterialDialog.ListCallbackSingleChoice() { @Override public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { sharedPref.edit().putString("dirontop", "" + which).commit(); dialog.dismiss(); return true; } }); a.build().show(); return true; } }); findPreference("sortby").setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { String[] sort = getResources().getStringArray(R.array.sortby); int current = Integer.parseInt(sharedPref.getString("sortby", "0")); MaterialDialog.Builder a = new MaterialDialog.Builder(getActivity()); if (theme == 1) a.theme(Theme.DARK); a.items(sort).itemsCallbackSingleChoice(current, new MaterialDialog.ListCallbackSingleChoice() { @Override public boolean onSelection(MaterialDialog dialog, View view, int which, CharSequence text) { sharedPref.edit().putString("sortby", "" + which).commit(); dialog.dismiss(); return true; } }); a.title(R.string.sortby); a.build().show(); return true; } }); // Feedback Preference preference3 = (Preference) findPreference("feedback"); preference3.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.fromParts("mailto", "hoanghiep8899@gmail.com", null)); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "Feedback : File Manager"); Toast.makeText(getActivity(), getActivity().getFilesDir().getPath(), Toast.LENGTH_SHORT).show(); File f = new File(getActivity().getExternalFilesDir("internal"), "log.txt"); if (f.exists()) { emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(f)); } startActivity(Intent.createChooser(emailIntent, getResources().getString(R.string.feedback))); return false; } }); // rate Preference preference5 = (Preference) findPreference("rate"); preference5.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { Intent intent1 = new Intent(Intent.ACTION_VIEW); intent1.setData(Uri.parse("market://details?id=com.filemanager.free")); try { startActivity(intent1); } catch (ActivityNotFoundException e) { e.printStackTrace(); } return false; } }); // Colored random color final SwitchPreference randomColor = (SwitchPreference) findPreference("random_checkbox"); randomColor.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { if (preferences != null) preferences.changed = 1; Toast.makeText(getActivity(), R.string.setRandom, Toast.LENGTH_LONG).show(); return true; } }); // Colored navigation bar final SwitchPreference colorNavigation = (SwitchPreference) findPreference("colorednavigation"); colorNavigation.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { if (preferences != null) { preferences.changed = 1; } AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(getResources().getString(R.string.confirm)); builder.setMessage(getResources().getString(R.string.themeRestart)); builder.setPositiveButton(getResources().getString(R.string.ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { restartPC(getActivity()); } }); builder.setNegativeButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); builder.setCancelable(true); builder.show(); return true; } }); if (Build.VERSION.SDK_INT >= 21) { colorNavigation.setEnabled(true); } else { colorNavigation.setEnabled(false); } findPreference("skin").setOnPreferenceClickListener(this); findPreference("fab_skin").setOnPreferenceClickListener(this); findPreference("icon_skin").setOnPreferenceClickListener(this); findPreference("extractpath").setOnPreferenceClickListener(this); findPreference("zippath").setOnPreferenceClickListener(this); }
From source file:com.fisher.wxtrend.permission.EasyPermission.java
/** * OnActivityResult???//from w ww. j a va 2s .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#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();// w w w . jav a2 s . c o 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)); } } } }