authentication - 1 User Multiple Accounts 1 android app transfer data from login activity to splashscreen activity -
i'm developing app user must able switch between accounts. of i'm able allow app 1 account log in. how can allow user create account , switch between them in android app?
update:-
i'm able auth google button (firebase)
in login.class stored value of uid got firebase. want send data splashscreen check if uid==null redirect login , if uid !=null redirect mainactivity.
login.class
string mypreferences = "myprefs" ; string uid = "uidkey"; sharedpreferences sharedpreferences = login.this.getpreferences(context.mode_private); sharedpreferences.editor editor = sharedpreferences.edit(); editor.putstring("uid", uid); editor.putboolean("is_logged_before",true); //this line trick editor.commit(); toast.maketext(login.this,"uid:"+uid,toast.length_long).show(); string uid1 = sharedpreferences.getstring("uid", ""); log.i("shareduser",uid1); intent = new intent(login.this,splashscreen.class); i.putextra("message",uid1); startactivity(i);
splashscreen
public class splashscreen extends activity {
private static int splash_time_out = 2000; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.splashscreen); new handler().postdelayed(new runnable() { @override public void run() { /*bundle bundle = getintent().getextras(); string message = bundle.getstring("message"); log.i("received uid",message);*/ intent homeintent = new intent(splashscreen.this, login.class); startactivity(homeintent); finish(); } },splash_time_out); }
}
the scope of answer wide. please ask genuine doubts related programming only.
looks need implement auto-login of user. need use shared preferences.
after successful login of user, store username , password in shared preferences.
then when user again tries login need check sharedpref check username , password. again depends on type of authentication implementing can session id user.
check answer that
also account picker check answer
Comments
Post a Comment