How to support session timeout processing in an Android app

enter image description hereI am new to Android app development. I have a little problem. While working on your Android application, suddenly press the "Home" button to go to the background after a while, go to the "Home" again and click on the icon of my application it starts from my first screen again, instead I save the last viewed action and should show a message like "Your timeout session So, try again with a box with two EditText blocks." Then check the credentials and allow the user to continue or redirect to the login screen. How to do it.

Thanks in advance.

+5
4

Android. SharedPreferences.

.

 ==> when ever you are trying to maintain login concept save user name in the sharedpreference.
 ==> once data is edited in prefernces.xml , the data in it can be check in any Activity.

, , , :

 SharedPreferences pref = myContexy.getSharedPreferences("Session Data", MODE_PRIVATE);
 SharedPreferences.Editor edit = pref.edit();
 edit.putString("User Name", username);
 edit.putString("Password", password);
 edit.putInt("Session ID", session_id);
 edit.commit();

 SharedPreferences pref = myContexy.getSharedPreferences("Session Data", MODE_PRIVATE);
 username = pref.getString("User Name", "");
 password = pref.getString("Password", "");
 session_id = pref.getInt("Session ID", 0);
+3

SharedPreferences - , , , :

  • onPause() (- > SharedPreferences)
  • onResume() , -

-, , , , , : -)

, : /

+2

, , , inplace .

  • sendMessageAtTime (Message, long), long - . .
0
source

All Articles