android - getIntent().getExtra() returns null -
i have code direct users profile page bottom bar.
private void startnewintent(class classname, string uid){ intent intent = new intent(act, classname); intent.putextra("uid", uid); act.startactivity(intent); act.finish(); } classname = displayprofile.class; if(firebaseauth.getinstance().getcurrentuser() != null){ string uid = firebaseauth.getinstance().getcurrentuser().getuid(); startnewintent(displayprofile.class, uid); } else { startnewintent(emailpasswordactivity.class); }
in profileactivity.java
protected void oncreate(bundle savedinstancestate){ super.oncreate(savedinstancestate); string uid = getintent().getstringextra("uid"); if(uid != null){ ... } }
i tried bundle = getintent().getextra()
same results. have seen similar questions. seem case: getintent() extras null
i tried
intent.setflags(intent.flag_activity_single_top | intent.flag_activity_clear_top);
but getintent().getextra != null
still false.
thank , advice.
edit: added context startnewintent()
avoid ".class"
if present in class name.
public void startnewintent(class classname, string uid){ intent intent = new intent(act.this, classname+".class"); intent.putextra("uid", uid); startactivity(intent); }
next phase
@override protected void oncreate(bundle savedinstancestate){ super.oncreate(savedinstancestate); string uid = getintent().getextras().getstring("uid"); if(uid != null){ ... } }
Comments
Post a Comment