Conditionally set first activity in Android

后端 未结 4 1482
北荒
北荒 2020-12-31 02:23

Currently we have a splash screen that is displayed in our app. However, if there is no data to be gathered or processed that is waiting, we\'d like to go straight into our

4条回答
  •  被撕碎了的回忆
    2020-12-31 03:01

    You can do something like this:

    1. Your Splash Screen is the main activity (Launcher-Category)
    2. If your splash screen can load data (or whatever your splashscreen does), do it. After finished, close the spalsh screen (call finish()) and start the real first activity and pass the data as intent extra.
    3. If your splashscreen can not load data or (or whatever your splashscreen does), start the next Activity by using an Intent and finish the spalsh screen activity by calling finish()

    So the workflow of your app will be:

    1. Click on the launcher icon
    2. The Splash Screen Activity will always been started
    3. If spalsh screen can not load, than the activity will be finished immediately and the other activity will be started. Your app user will not notice that the splash screen activity if you finish() the splash screen activity immediately, because the activity is never shown on screen in this case

提交回复
热议问题