0

I have read this question: How do I implement a 'Remember me' function in an Android Activity? ,

I am developing "Login" Activity for the first-time, Where i am also having:

  1. two EditText: Username, Password
  2. One checkbpx: Remember me
  3. one Button: Login

If user click on Login Button then Username, Password should be shared among all activity, i know this can be implemented using SharedPreference.

But On "Remember me" checkbox, if user check it once then next-time "Login" Activity should not be appeared, directly 2nd activity should appear, so for that what i should do?

Community
  • 1
  • 1
Paresh Mayani
  • 127,700
  • 71
  • 241
  • 295
  • 1
    when the "Remember me" is enabled and a successful login occurs, you simply enable a flag in SharedPref that signifies this Event...along with that, you'll have to save the Username and Password (preferably in some encrypted form) so that the login can be done. – st0le Sep 08 '10 at 12:07
  • hi paresh..you got the solution for that?..if so pls share with me.. – Vijaya Jul 02 '11 at 05:31

2 Answers2

2

For this Scenario, I do that Before Login Activity i have Splash Screen to check whether the Remember Password option enabled or not on the Login Activity.

Splash Screen Also a Activity that has just a well designed image about my App (like loading App screen). Its show for just 3 seconds.

example for Splash Screen in this link

Praveen
  • 90,477
  • 74
  • 177
  • 219
1

In the onCreate() method of your Login Activity, before calling setContentView() check 'Remember Me' status and if it is true, then call startActivity() to open the next Activity. Something like :

@Override
protected void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);

  if(isRememberMeChecked()) {
    startActivity(intentForSecondActivity);
    return;
  }

  setContentView(R.layout.act_first);
  ....
  ...
  ..
  .

}

Here,isRememberMeChecked() is just a simple method which returns a boolean value depending on the Remember Me status, say if I'm using SharedPreferences to store the status, then my method will be :

private boolean isRememberMeChecked() {
  return sPref.getBoolean(C.REMEMBER_ME, false);
}
desidigitalnomad
  • 1,443
  • 21
  • 33