0

I have an Android application (let's call AppA) that will use an intent to call another application (AppB), using the method described here :

Launch an application from another application on Android

Using these approach, when I press the back button on AppB I return to the AppA as expected. But, I noticed that, when I navigate to Home screen and then call the 'recent applications' screen, both apps appears there, so, I can reopen each AppA and AppB and use them, independently.

Is there any way to avoid this behavior? In my scenario the user cannot manipulate AppA if AppB was opened from it. So, if the user switched to home when AppB was opened from AppA, when switching back to AppA, the user should see the AppB, since it should be unable to use AppA without closing AppB first.

Thanks.

Community
  • 1
  • 1
regisxp
  • 867
  • 2
  • 10
  • 27

2 Answers2

3

Use the FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS flag

Intent i = new Intent(this, AppB);
i.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
startActivity(i);
Hoan Nguyen
  • 17,479
  • 3
  • 47
  • 51
0

You can remove your Activity from Recent Apps list programmatically. For example see this question:

Remove app from recent apps programmatically

Community
  • 1
  • 1
hasanghaforian
  • 13,142
  • 8
  • 71
  • 144
  • Hi @hasanghaforian. +1 for the very interesting information, but it wasn´t what I was looking for. Thanks! – regisxp Apr 01 '13 at 11:40