1

I can specify an activity to launch in an app with the the following inside AndroidManifest.xml

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>

In my app, a few Activities A,B,C... are needed to initialize it. They will only be shown during the initial installation but not afterwards.

Right now, I use Activity X as default one and call startActivity() within X. However, Activity X is not fully initialized while A,B,C are being displayed and pressing back key can show X in its not fully initialized state which is ugly.

How can I programmatically decide which activity to launch based on some persisted state?

windchime
  • 1,253
  • 16
  • 37
  • launcher category is the only way for android to provide the begin path. then you can specify intents for next one. – Ranjit Mar 28 '14 at 21:27
  • if user presses the back key, then, the starting activity will be shown. Is there a way to avoid it? – windchime Mar 28 '14 at 21:30
  • "pressing back key can show X in its not fully initialized state which is ugly" -- then you should not be showing X. `finish()` it when it starts A. C will call `startActivity()` to start X up again. – CommonsWare Mar 28 '14 at 21:34
  • if you don't want to see the activity again then finish it in onpause()..and if your problem is back key then simple override the onBackKeyPressed() in your 2nd activity and don't write anything inside it.then back key will not work after click. – Ranjit Mar 28 '14 at 21:34
  • possible duplicate of [Define Default Activity (when app starts) programmatically](http://stackoverflow.com/questions/6497725/define-default-activity-when-app-starts-programmatically) – Slava Fomin II Mar 06 '15 at 09:28

0 Answers0