0

I am starting activities(one or more) of another android application from one of the activities(Activity A) of my application to run some test scripts. After running, I want Activity A to be brought to the foreground the activities of the other application to be closed.

I am trying to achieve this by setting the launchMode of Activity A as singleTop in the manifest and using this snippet:

Intent intent = new Intent(getApplication(), ActivityA.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_CLEAR_TOP); //Clear Top Flag
startActivity(intent);

I have also tried using Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK when launching ActivityA which will clear the entire task and create a new instance of ActivityA whereas I want the running instance of ActivityA to be brought to foreground

I have also tried to implement code samples from this link

Thanks in advance

Community
  • 1
  • 1
Narasimha
  • 61
  • 2
  • 5

1 Answers1

0
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);

This will bring the specified activity to top of the stack and clear rest of them.

Slashbin
  • 668
  • 5
  • 15