1

My Launcher class name is "SplashScreen". I have two Activities "MainActivity" and "MenuList". When user opens the app, SplashScreen Activity is started. Splash Screen Activity validates and starts MainActivity. User opens MenuList Activity by clicking on button in MainActivity Screen and clicks on home button in MenuList Activity. When user opens the app it should directly open MenuList Activity. I have made changes as mentioned in below link. It is working fine when user press home button in MainActivity. It is not working when user press home button in MenuList Activity. Please help me.

https://stackoverflow.com/a/20815679/1517280

ScreenFlow: SplashScreen -> MainActivity -> MenuList

Manifest code:

 <activity
            android:name=".SplashScreenActivity"
            android:clearTaskOnLaunch="true"
            android:launchMode="singleTask"
            android:screenOrientation="portrait" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
<activity
            android:name=".MainActivity"
            android:windowSoftInputMode="adjustResize|stateHidden"
            android:screenOrientation="portrait" />


<activity
            android:name=".MenuList"
            android:windowSoftInputMode="adjustResize|stateHidden"
            android:screenOrientation="portrait" />
  • remove both `android:clearTaskOnLaunch` and `android:launchMode` from `SplashScreen`. Also remove the funky code you added from the linked answer. You don't need any of that. The behaviour you want is standard Android behaviour. – David Wasser Jun 19 '17 at 15:10

1 Answers1

0

Remove android:clearTaskOnLaunch="true" from SplashActivity's element.

In fact, this doesn't work for your MainActivity either - since this flag is set, every time you get back to your application, the task's stack is being cleared and SplashActivity is being launched.

Vasiliy
  • 16,221
  • 11
  • 71
  • 127
  • I have added below code in SplashActivity. It is working fine for MainActivity protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) { // Activity was brought to front and not created, // Thus finishing this will get us to the last viewed activity finish(); return; } // Regular activity creation code... } – Srikanth Reddy Ramidi Jun 19 '17 at 13:00
  • Thanks. It is working now. I have removed android:clearTaskOnLaunch="true" from SplashActivity – Srikanth Reddy Ramidi Jun 20 '17 at 07:15
  • @SrikanthReddyRamidi, then consider accepting the answer. – Vasiliy Jun 20 '17 at 07:31