0

Scenario:

  • Activity A (MAIN and LAUNCHER in manifest) starts up when clicking on launcher icon.

  • In turn it launches Activity B.

  • Activity B then launches our main app Activity C (MAIN and singleTask in manifest).

Behaviour I require:

Once Activity C has been shown and the home key is then pressed, the next time the launcher icon is pressed I would like to skip straight to Activity C (and not show Activity A (and consequently B) again).

I have tried using FLAG_ACTIVITY_CLEAR_TOP from A, but I still get Activity A whenever I hit icon on launch screen.

Is appearance of my singletask Activity C from launcher achievable?

Update: Use of FLAG_ACTIVITY_CLEAR_TOP from A and not calling finish() creates the situation whereby Activity B appears on press of launcher icon. However, also applying use of FLAG_ACTIVITY_CLEAR_TOP from B and not calling finish() does not resolve situation. now I don't get A on launcher icon press, but get B. What gives!

CoastalB
  • 695
  • 4
  • 15
  • Is your Activity `A` and `B` just like Splash screen which should appear only the first time when user launch the application after installing it. Or should it appear each time the appication is restarting after closing? – Shobhit Puri Aug 08 '13 at 17:09
  • It should appear after each "close" of Activity C. – CoastalB Aug 08 '13 at 17:47

1 Answers1

0

See similar scenario here.

In your case, I would recommend using a similar approach, where you would have a SharedPreference that would persist a value representing whether your app had previously been launched.

Create a simple Activity that will contain the logic for what you are trying to do here. In that activity's ("pre-A" Activity) onResume() method, check the value of the preference representing whether the app has ran previously.

If it has not previously been ran, launch an intent to Activity A, which calls the subsequent B and C activities; otherwise, launch an intent to Activity C.

Seems pretty straightforward, just remember to define the new "Pre-A" activity in your manifest!

Community
  • 1
  • 1
Devin
  • 81
  • 1
  • 3
  • I already have shared prefs in place, I am just not using it presently for this situation. I just wanted to check if there was a different (and perhaps more recommended) approach... – CoastalB Aug 08 '13 at 17:50