List of usage examples for android.app Activity finish
public void finish()
From source file:com.mediatek.contacts.activities.ActivitiesUtils.java
public static boolean checkPhoneBookReady(final Activity activity, Bundle savedState, int subId) { if (subId > 0 && !SimCardUtils.isPhoneBookReady(subId)) { Log.w(TAG, "[checkPhoneBookReady] phone book is not ready. mSubId:" + subId); activity.finish(); return true; }/*from w w w .ja v a2 s . co m*/ if ((MultiChoiceService.isProcessing(MultiChoiceService.TYPE_DELETE) || MultiChoiceService.isProcessing(MultiChoiceService.TYPE_COPY) || VCardService.isProcessing(VCardService.TYPE_IMPORT) || MultiGroupPickerFragment.isMoveContactsInProcessing() //M:FixedALPS00567939 ) && (savedState == null)) { Log.d(TAG, "[checkPhoneBookReady]delete or copy is processing "); activity.runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(activity.getApplicationContext(), R.string.phone_book_busy, Toast.LENGTH_SHORT) .show(); } }); activity.finish(); return true; } return false; }
From source file:com.evozi.droidsniff.helper.DialogHelper.java
public static void showDisclaimer(final Activity context) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(R.string.license); builder.setPositiveButton("Agree", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel();/*from ww w. j av a2s .c om*/ } }).setNegativeButton("Disagree", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { context.finish(); } }); builder.setCancelable(false); builder.show(); }
From source file:Main.java
public static void showNfcSettingsDialog(final Activity app) { new AlertDialog.Builder(app).setTitle("NFC is disabled").setMessage("You must enable NFC to use this app.") .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { app.startActivity(new Intent(android.provider.Settings.ACTION_NFC_SETTINGS)); }//from w w w .j a va2s.co m }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { app.finish(); } }).setIcon(android.R.drawable.ic_dialog_alert).show(); }
From source file:com.mediatek.contacts.activities.ActivitiesUtils.java
/** New Feature */ public static boolean checkSimNumberValid(Activity activity, String ssp) { if (ssp != null && !PhoneNumberUtils.isGlobalPhoneNumber(ssp)) { Toast.makeText(activity.getApplicationContext(), R.string.sim_invalid_number, Toast.LENGTH_SHORT) .show();/* w ww. j a va 2 s . com*/ activity.finish(); return true; } return false; }
From source file:edu.stanford.junction.android.AndroidJunctionMaker.java
/** * Finds a pre-existing Junction activity by scanning for a QR code. * @param context/*w ww. j a v a 2s . c o m*/ */ public static void findActivityByScan(final Activity activity) { WaitForInternetCallback callback = new WaitForInternetCallback(activity) { @Override public void onConnectionFailure() { activity.finish(); } @Override public void onConnectionSuccess() { Intent intent = new Intent("junction.intent.action.join.SCAN"); intent.putExtra("package", activity.getPackageName()); IntentLauncher.launch(activity, intent, "edu.stanford.prpl.junction.applaunch", "http://prpl.stanford.edu/android/JunctionAppLauncher.apk", "Activity Director"); } }; try { WaitForInternet.setCallback(callback); } catch (SecurityException e) { Log.w("junction", "Could not check network state. If you'd like this functionality, please add the permission: android.permission.ACCESS_NETWORK_STATE", e); callback.onConnectionSuccess(); } }
From source file:com.ccs.wedate.common.eventbus.util.ErrorDialogFragments.java
public static void handleOnClick(DialogInterface dialog, int which, Activity activity, Bundle arguments) { if (EVENT_TYPE_ON_CLICK != null) { Object event;/*from ww w . ja v a 2s . co m*/ try { event = EVENT_TYPE_ON_CLICK.newInstance(); } catch (Exception e) { throw new RuntimeException("Event cannot be constructed", e); } EventBus eventBus = ErrorDialogManager.factory.config.getEventBus(); eventBus.post(event); } boolean finish = arguments.getBoolean(ErrorDialogManager.KEY_FINISH_AFTER_DIALOG, false); if (finish && activity != null) { activity.finish(); } }
From source file:Main.java
/** * Creates a simple alert dialog with given params * * @param activity self explanatory//from w w w. j av a2s . co m * @param title self explanatory * @param message self explanatory */ public static void createAlertDialog(final Activity activity, String title, String message) { AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(activity); // set title alertDialogBuilder.setTitle(title); // set dialog message alertDialogBuilder.setMessage(message).setCancelable(false).setPositiveButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { // if this button is clicked, close // current activity dialog.cancel(); activity.finish(); } }); }
From source file:com.android.contacts.activities.RequestPermissionsActivityBase.java
protected static boolean startPermissionActivity(Activity activity, String[] requiredPermissions, boolean isCallerSelf, Class<?> newActivityClass) { if (!hasPermissions(activity, requiredPermissions)) { final Intent intent = new Intent(activity, newActivityClass); activity.getIntent().putExtra(EXTRA_STARTED_PERMISSIONS_ACTIVITY, true); intent.putExtra(PREVIOUS_ACTIVITY_INTENT, activity.getIntent()); intent.putExtra(EXTRA_IS_CALLER_SELF, isCallerSelf); activity.startActivity(intent);/*from ww w . j av a 2 s .co m*/ activity.finish(); return true; } // Account type initialization must be delayed until the Contacts permission group // has been granted (since GET_ACCOUNTS) falls under that groups. Previously it // was initialized in ContactApplication which would cause problems as // AccountManager.getAccounts would return an empty array. See b/22690336 AccountTypeManager.getInstance(activity); return false; }
From source file:de.baumann.hhsmoodle.helper.helper_main.java
public static void switchToActivity(Activity activity, Class to, boolean finishActivity) { Intent intent = new Intent(activity, to); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); activity.startActivity(intent);/* w ww . j a v a2s .c om*/ if (finishActivity) { activity.finish(); } }
From source file:Main.java
/** * Helper method to recreate the Activity. This method should be called after a Locale change. * @param activity the Activity that will be recreated * @param animate a flag indicating if the recreation will be animated or not */// w ww . j av a 2 s .c o m public static void recreate(Activity activity, boolean animate) { Intent restartIntent = new Intent(activity, activity.getClass()); Bundle extras = activity.getIntent().getExtras(); if (extras != null) { restartIntent.putExtras(extras); } if (animate) { ActivityCompat.startActivity(activity, restartIntent, ActivityOptionsCompat .makeCustomAnimation(activity, android.R.anim.fade_in, android.R.anim.fade_out).toBundle()); } else { activity.startActivity(restartIntent); activity.overridePendingTransition(0, 0); } activity.finish(); }