1

i am launching another application through my application,so i want to check is any instance of that application is already in stack or not? if exist then clear all instance before launch.

baske
  • 1,316
  • 9
  • 16
MR. Kumar
  • 661
  • 8
  • 25

2 Answers2

2

Would you be looking for the following flags to add to the Intent you start the other application with:

FLAG_ACTIVITY_CLEAR_TASK

baske
  • 1,316
  • 9
  • 16
  • is it possible to clear another application stack through FLAG_ACTIVITY_CLEAR_TASK from other appliction? – MR. Kumar Jun 03 '13 at 10:58
  • Well that is exactly what the documentation states. In fact it can _only_ be used to clear the stack of another application, because as the documentation also states the flag _must_ be used in conjunction with FLAG_ACTIVITY_NEW_TASK (by the way, in Android context you usually refer to "tasks" rather than "applications") – baske Jun 03 '13 at 11:04
2

Try adding this flags to your intent

Intent intent= getPackageManager().getLaunchIntentForPackage("com.package.address");

intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); 
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
Nirali
  • 13,571
  • 6
  • 40
  • 53