1

I have my app, first time its opened it opens splash screen ( activity 1) and moves to second page(activity 2) to ask for username/password.User loggs in i save things in sharedpreferences ( sessionid). Later when the app is closed, and reopened same thing splash screen(activity 1) is opened however this time since user already logged in ( i get to read sessionid via sharedpreferences on splash screen) i automatically take him in to activity 3.

My problem is , i am doing on splash screen the check whether he is already logged in or not. i want to remove splash screen (activity 1) part. open the login screen first time ( activity 2), and if its logged in second time it opens the app directly to (activity 3). How can I do this? Just like gmail?

krikor Herlopian
  • 731
  • 1
  • 10
  • 23
  • simple when second activity started just check that if your sharepref have some data then put a intent to third screen if not then login.. – Manish Oct 15 '16 at 12:31
  • you should check [this answer](http://stackoverflow.com/a/29517717/3134215) – Ravi Oct 15 '16 at 12:31

2 Answers2

0

Move your authentication code to another class. The authentication class should handle the caching of the username and password and handle the username and password checking when the user logs in the first time. Before you show the splash screen check have a method which checks if the user is cached. If the user is then go directly to activity three. If not then show the splash screen and allow the user to login. The login activity will also use the authentication class to validate the username and password.

fsebek
  • 389
  • 2
  • 9
0

I have solve this issue in my mobile app. I have use in my mobile app first time login using username/email and password with login application after successfully login store data in session and also in url pass authentication key use so after some time my session destroy but in this case i have retrieve data using my unique authentication key so not redirect login page after session destroyed and if remove mobile cache then redirect login page.

test
  • 1
  • 2