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