You can save the login status (true / false) in sharedPreferences . Now for the second requirement, two cases may arise.
When the user exits HomeActivity , the application will be in the background in live mode, but in a passive state, in this case you do not need to do anything when the user restarts the application from recent tasks or from the Android launcher automatically starts viewing the last action (i.e. e. HomeActivity in your case).
While the application was in the background, someone killed , that is, Android OS to approve memory for some other application, you restarted the phone, killed some task killers, etc. In this case, when the user starts the Application again, Android will launch the default launch action, i.e. LoginActivity , you need to check the variable stored in SharedPreferences inside OnResume of LoginActivity. If the user has already logged in, just start HomeActivity to start normal behavior.
Not only a boolean variable in which you can store anything , you will need to launch HomeActivity .
source share