android - Passing data from two different intent in one activity to another activity -


how can pass different value different intent inside activity. i.e

activity a:

buttona .onclick{

    intent.putextra("name", screenname);      intent.putextra("email", description);      intent.putextra("pic", twitterimage);      startactivity(intent); 

}

buttonb. onclick{

    intent.putextra("anothervalue", json_object.tostring()) 

}

activity b:

  intent intent = getintent();    string getvalue = intent.getstringextra("value of button clicked") 

while david rauca answer correct, face nullpointerexception.

getintent().getstringextra("firstvalue") cause npe if there no value name 'firstvalue'.

you should check whether or not value exist this.

if(getintent().hasextra("firstvalue")) {     string firstvalue = getintent().getstringextra("firstvalue"); } 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -