Java Code Examples for android.app.Activity#finishAffinity()
The following examples show how to use
android.app.Activity#finishAffinity() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PermissionAcquire.java From NetCloud_android with GNU General Public License v2.0 | 6 votes |
@Override public void onPermissionDenied() { Activity activity = (Activity)ContextMgr.getContext(); if(activity != null){ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { activity.finishAffinity(); }else{ activity.finish(); } } new Handler().postDelayed(new Runnable() { @Override public void run() { Process.killProcess(Process.myPid()); } }, 200); }
Example 2
Source File: AccountManager.java From deltachat-android with GNU General Public License v3.0 | 6 votes |
@Override protected void onPostExecute(Void result) { Activity activity = activityWeakReference.get(); if (activity!=null) { activity.finishAffinity(); if (destAccount==null) { Intent intent = new Intent(activity, WelcomeActivity.class); if (qrAccount!=null) { intent.putExtra(WelcomeActivity.QR_ACCOUNT_EXTRA, qrAccount); } activity.startActivity(intent); } else { activity.startActivity(new Intent(activity.getApplicationContext(), ConversationListActivity.class)); } } }
Example 3
Source File: CommonUtils.java From firebase-android-sdk with Apache License 2.0 | 5 votes |
/** * Finish this activity, and tries to finish all activities immediately below it in the current * task that have the same affinity. * * <p>On Android 4.1+ calling this method will call through to the native version of this method. * For other platforms will {@link Activity#setResult(int)} with @param resultCode and immediatly * after {@link Activity#finish()} will be called instead. */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN) public static void finishAffinity(Activity activity, int resultCode) { if (activity == null) { return; } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { activity.finishAffinity(); } else { activity.setResult(resultCode); activity.finish(); } }
Example 4
Source File: CommonUtils.java From letv with Apache License 2.0 | 5 votes |
@TargetApi(16) public static void finishAffinity(Activity activity, int resultCode) { if (activity != null) { if (VERSION.SDK_INT >= 16) { activity.finishAffinity(); return; } activity.setResult(resultCode); activity.finish(); } }
Example 5
Source File: ApplicationUtil.java From QuickDevFramework with Apache License 2.0 | 5 votes |
/** * restart application * * <p> * Stop all active activities and launch application again with default launch intent. * Start activity from background without permission is not allowed since Android Q, * AlarmManager method won't work without grant permission * </p> * @param activity activity instance */ public static void restartApplication(Activity activity) { if (activity != null) { activity.finishAffinity(); } String packageName = ContextProvider.get().getPackageName(); Intent mStartActivity = ContextProvider.get().getPackageManager().getLaunchIntentForPackage(packageName); if (mStartActivity == null) { return; } mStartActivity.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); mStartActivity.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); ContextProvider.get().startActivity(mStartActivity); }
Example 6
Source File: IslandSetup.java From island with Apache License 2.0 | 5 votes |
private static void deactivateDeviceOwner(final Activity activity) { Analytics.$().event("action_deactivate").send(); final DevicePolicies policies = new DevicePolicies(activity); policies.getManager().clearDeviceOwnerApp(activity.getPackageName()); try { // Since Android 7.1, clearDeviceOwnerApp() itself does remove active device-admin, policies.execute(DevicePolicyManager::removeActiveAdmin); } catch (final SecurityException ignored) {} // thus SecurityException will be thrown here. activity.finishAffinity(); // Finish the whole activity stack. System.exit(0); // Force termination of the whole app, to avoid potential inconsistency. }
Example 7
Source File: i.java From MiBandDecompiled with Apache License 2.0 | 4 votes |
public static void a(Activity activity) { activity.finishAffinity(); }
Example 8
Source File: ActivityCompatJB.java From CodenameOne with GNU General Public License v2.0 | 4 votes |
public static void finishAffinity(Activity activity) { activity.finishAffinity(); }
Example 9
Source File: ActivityCompatJB.java From adt-leanback-support with Apache License 2.0 | 4 votes |
public static void finishAffinity(Activity activity) { activity.finishAffinity(); }
Example 10
Source File: ActivityCompatJB.java From V.FlyoutTest with MIT License | 4 votes |
public static void finishAffinity(Activity activity) { activity.finishAffinity(); }
Example 11
Source File: ActivityCompatJB.java From guideshow with MIT License | 4 votes |
public static void finishAffinity(Activity activity) { activity.finishAffinity(); }
Example 12
Source File: ApplicationUtil.java From QuickDevFramework with Apache License 2.0 | 3 votes |
/** * close application * <p> * Stop all active activities and call Runtime.exit() after 500ms * </p> * @param activity activity instance */ public static void exitApplication(Activity activity) { if (activity != null) { activity.finishAffinity(); } new Handler().postDelayed(() -> Runtime.getRuntime().exit(0), 500); }
Example 13
Source File: Main.java From Bop with Apache License 2.0 | 1 votes |
/** * Forces the whole application to quit. * <p> * Please read more info on this StackOverflow answer: * http://stackoverflow.com/a/4737595 * * @note This is dangerous, make sure to cleanup * everything before calling this. */ public static void forceExit(Activity c) { c.finish(); c.finishAffinity(); }