Android: How do I totally remove an Activity from the Activity Stack?

前端 未结 5 1446
梦毁少年i
梦毁少年i 2021-01-07 02:34

I have two Activities FirstActivity and SecondActivity.

FirstActivity has an intent filter MAIN, LAUNCHER and DEFAULT. SecondActivity is just a normal activity and n

相关标签:
5条回答
  • 2021-01-07 02:48

    It is the correct behavior.. if you start the application through "Recent Application" it will point from the last activity. Try launching it through normal application list

    0 讨论(0)
  • 2021-01-07 02:51

    For your main Activity try to set the lauch mode as "singleInstance" in the AndroidManifest file. for second activity set "Finish On Task launch" to true.

    0 讨论(0)
  • 2021-01-07 02:51

    you can call your second activity with the flag set no history like this,

    intent1.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    

    This has worked for me several times.

    Read from the Android Doc

    0 讨论(0)
  • 2021-01-07 02:53

    In Second scenario i think activity stack is empty as app is closed . so now you are starting activity2 , means this is the only activity in stack . now desired back behavior can be possible by overriding onbackpress and start activity1 if its second scenario .

    0 讨论(0)
  • 2021-01-07 02:58

    When you start application from 'Recent Application' shortcut, it will launch the last activity. So you can try to launch the application from the application list, see whether it solves your problem.

    0 讨论(0)
提交回复
热议问题