Monday, 27 April 2015

Clear all multiple instances of single app android

In this post we have learned about to Clear multiple instances of single app  android with code.

In Java file you have to mentioned the following code:

if (!isTaskRoot()) { final Intent intent = getIntent(); final String intentAction = intent.getAction(); if (intent.hasCategory(Intent.CATEGORY_LAUNCHER) && intentAction != null && intentAction.equals(Intent.ACTION_MAIN)) { finish(); } }

In Manifest file mention the following code for activity
android:launchMode="singleTask"

How to close All opened stack of activities in android

Intent intent = new Intent(this, Home.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); intent.addFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
startActivity(intent);

No comments:

Post a Comment