0

I am developing app where user can fill the form and sync it with the server once he comes in network range.

For security purpose I am veryfying user with login id, password and device Id. My first screen is login screen, second is form list and third is actual form.

My Problem is whenever phone gets restarted, by default login screen appear, Even User is on second or third page when phone is restarting.

I am using shared preferrance for saving data offline. That data remains persist. But problem lies if user went to remote place (Where network is not available easily) and reboot the phone by mistake, he have to login again.

I wants to make sure that if user is once logged in, even after phone reboot he will get redirected to second activity

user1774890
  • 117
  • 1
  • 2
  • 10

2 Answers2

1

Common way for keeping user logged in, in android is keeping users conditionals. So user logs in once, application saves username, password, access token etc. whatever it needs to be able to re-login the user.

Your login screen should check if there is any login info saved, if so it should login automatically,if not it should let the user login and save the login info for further use. And don't forget to give a way to the user to be able logout, a logout button maybe.

For further info check out AccountManager

Onur
  • 5,617
  • 3
  • 26
  • 35
0

Usually when the device reboots all the apps are killed before the boot is complete, so when you launch the activity again there is no instance of your activity with the task manager so it launches it as a new app launch. If you want your user to go to the last navigated activity then you need to save your activity in shared prefence in onPause() and start your app with this activity when the device reboots. You can implement it as described in the following link :

How to make an android app return to the last open activity when relaunched?

Hope this helps you to achieve what is required.

Community
  • 1
  • 1
CodeWarrior
  • 5,026
  • 6
  • 30
  • 46