How to always start from a startup activity on Android?

后端 未结 9 1318
走了就别回头了
走了就别回头了 2020-12-09 10:52

There are three different cases:

1) A user launches an app, navigates in it, pressed home and click on the app icon again to launch our app again.

2) A user

相关标签:
9条回答
  • 2020-12-09 11:50

    You can call this.finish() on the onPause() of your Activity, that way the activity will be closed in the three cases.

    0 讨论(0)
  • 2020-12-09 11:53

    1) define a public static normalPause = true variable in a Class.

    2) in onPause method of all of your activities set it false (I am worry. We might not be in a normal pause)

    2) in onCreate method of all of your activities set it true (Do not worry. We are in a normal pause)

    3) in onResume of all of your Activities:

    if(!Utilities.normalPause)
    {
        this.finish()
    }
    

    Enjoy!

    0 讨论(0)
  • 2020-12-09 11:53

    Perhaps, android:noHistory is what you're looking for. If you declare all your activities except StartupActivity with this attribute, then they will be finished as the user navigates away from them and only StartupActivity will appear.

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