android - I am not able to pass the values from one activity to another -


i trying values edittext 1 activity , trying send , receive values in activity. unable values. not opening receiving activity after values entered . opening activity after login. code follows

mainactivity.java

                    toast.maketext(mainactivity.this, "successful registration", toast.length_short).show();                     intent = new intent(mainactivity.this, login_activity.class);                       string name,mobile;                     name = username.gettext().tostring();                     mobile = usermob.gettext().tostring();                       bundle i2 = new bundle();                     i2.putstring("uname", name);                     i2.putstring("unumber",mobile);                     i.putextras(i2);                     startactivity(i);                     /*toast.maketext(mainactivity.this, "captcha not match", toast.length_short).show();*/ 

referralpage.java

                    package com.mws.tms_application;                      import android.content.intent;                     import android.os.bundle;                     import android.support.v7.app.appcompatactivity;                     import android.widget.edittext;                     import android.widget.textview;                      public class referralpage extends appcompatactivity {                           @override                         protected void oncreate(bundle savedinstancestate) {                             super.oncreate(savedinstancestate);                             setcontentview(r.layout.activity_referral_page);                                // mainactivity mn=new mainactivity();                             textview tv= (textview) findviewbyid(r.id.referralcode);                             edittext ed1= (edittext) findviewbyid(r.id.username_edtext);                             edittext ed2= (edittext) findviewbyid(r.id.usermob_no_edtext);                              intent intent = getintent();                           /*  string name = intent.getextras().getstring("uname");                             string mobile = intent.getextras().getstring("unumber");*/                      /*                             name=ed1.gettext().tostring();                             name=name.substring(0,3);                             number=ed2.gettext().tostring();                             number=number.substring(7,9);*/                            bundle bundle = getintent().getextras();                             system.out.print("intent called");                             if (bundle != null) {                                 string name = bundle.getstring("uname");                                 system.out.print("intent runned");                                 tv.settext(name/*+bundle.getextras().getstring("unumber")*/);                             }                             else{                                 tv.settext("your referral code");                             }                              // tv.settext(new stringbuilder().append(name).append(mobile).tostring());                         }                     } 

try send data this

string name,mobile; name = username.gettext().tostring(); mobile = usermob.gettext().tostring();  intent = new intent(mainactivity.this, login_activity.class);  i.putextra("name", name); i.putextra("mobile", mobile); startactivity(i); 

now receive data in activity this

string name = getintent().getextras().getstring("name"); string mobile = getintent().getextras().getstring("mobile"); 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -