Android : how to maintain session on back button? -


my app contains 2 activity classes. first activity user can login , second activity user can view project details.i'm maintaining session logout button. in app if user clicked on button second activity goes apps section(means main menu) , after time user clicked on app icon goes first activity not second activity yet user didn't logout.
i want user should go second activity not first activity if user login. had tried not working , still trying.
how can above stuff please suggest me answer.

you should save state of current user in sharedpreferences.

in oncreate method of login activity, before call setcontentview(), can check if user logged in. if true open new activity wish startactivity() , call finish() on current activity. if not continue normal setcontentview() call.

this way login activity not visible if state inside sharedpreferences set logged in.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -