Android: creating a “first time user” activity

前端 未结 1 1077
轻奢々
轻奢々 2021-01-15 08:52

I want to have an activity with registration for the users who run my app for the very first time. I don\'t want the user to be able to go past this registration activity, i

相关标签:
1条回答
  • 2021-01-15 09:32

    I am not sure where I should start the registration activity (before or after super.onCreate(savedInstanceState) ?)

    You should have your super() call as the first call when doing opening functions like onCreate(), onResume(), etc.... This way the function can do everything that the super() call needs to in order for the function to be ready. This isn't always a problem but safer to make the call first. Finishing functions such as onBackPressed(), finish(), etc... should have the super() call after you do your cleanup such as saving data.

    The MainActivity seems to keep working in the background and creates errors (because the user is not registered)

    Make the RegistrationActivity the launcher Activity and check if the user is registered and if so start the MainActivity else display your registration code or whatever you do in this case.

    The user can go to the MainActivity by pressing the back button

    See the previous solution. If the MainActivity is only started from the RegistrationActivity then this won't be an issue.

    Checking the SharedPreferences to see if the user is registered shouldn't cause much of a delay so you can do this before creating the layout for that Activity and go to the MainActivity if they are registered. If for some reason you are noticing much of a delay then you can make a splash screen to show your logo or whatever while you check for registered or not then take appropriate actions by going to either the registration or main Activity.

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