Is there any design pattern for creating an application with user login in Android.
My question is:
Any help or even links to documents on this topic is greatly appreciated.
Where do we keep the login session for user that wants to stay logged id in Android apps?
Static data. Have some sort of singleton that represents the login session. When the process is terminated due to inactivity, the user will need to log in again.
Should there be a RootActivity that first checks whether user is logged in, if yes then redirect to HomeActivity otherwise redirect to LoginActivity?
If you have to lazy-create the singleton, or otherwise determine that the user is not logged in, redirect the user to a login activity. You will need to do this from every activity (e.g., in onResume()
), since any activity can be an entry point into your app (e.g., from the recent tasks list).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With