android - Perform different operations depending on the parent activity? -


i know how intent started current activity, how should structure code if user comes in login page 1 thing happens, , if come signup page, thing happens?

class login extends activity { public final static string extra_message = "net.asdqwe.activities.login.extra_message";  //code here  public void onclick(view arg0) {         intent sendloggedinusertohomepage = new intent(getapplicationcontext(), home.class);         sendloggedinusertohomepage.putextra(extra_message,useremailloginpage);         startactivity(sendloggedinusertohomepage);     }  }   } 

asd

class signup extends activity { public final static string extra_message = "net.asdqwe.activities.signup.extra_message";  //code here   public void onclick(view arg0) {         intent signupsuccesshome = new intent(getapplicationcontext(), home.class);         signupsuccesshome.putextra(extra_message, useremail);         startactivity(signupsuccesshome);     } } 

and in home class , dont know do. until now, had signup page, easy:

intent loggedinuser = getintent(); useremailid = loggedinuser.getstringextra(signup.extra_message); userinfo = dbtools.getuserinfo(useremailid); 

but how change code have users coming login well?

add below code in home class

string reqfrom = "";  bundle b = this.getintent().getextras();  if (b != null)  reqfrom = b.getstring("reqfrom");  if(reqfrom.equalsignorecase("login")){ // action } else { // other action } 

add below code in login page.

intent sendloggedinusertohomepage = new intent(getapplicationcontext(), home.class); i.putextra("reqfrom", "login"); startactivity(sendloggedinusertohomepage); 

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -