java - Cannot pass two strings from one activity to another activity at same time -


i have 2 activities select , upload. passing 2 strings id , scan_id 1 activity another. value passes correctly when pass id alone. when try pass both values 1 value overrides other value. there separate way pass 2 strings???

selectactivity.java

public class selectactivity extends activity { string v1; public static string extra_message_id; public static string extra_message_scan; int flag; string strflag;  strictmode.threadpolicy policy = new strictmode.threadpolicy.builder()                                     .permitall()                                     .build();   @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_select);      bundle b = getintent().getextras();     edittext ed=(edittext)findviewbyid(r.id.patient_id);     ed.settext(b.getcharsequence("contents"));      button button = (button) findviewbyid(r.id.button1);     strictmode.setthreadpolicy(policy);      button ctbutton = (button) findviewbyid(r.id.ctscan);     ctbutton.setonclicklistener(new view.onclicklistener() {      @override     public void onclick(view v) {             flag=1;             strflag = string.valueof(flag);             log.e("log_tag", "sel id"+flag);             log.e("log_tag", "sel scan"+v1);              intent intent = new intent(selectactivity.this,mainactivity.class);             intent.putextra(extra_message_id,v1);             intent.putextra(extra_message_scan,strflag);             startactivity(intent);         }     }); } } 

mainactivity.java

public class mainactivity extends activity {       private static final string tag = mainactivity.class.getsimplename();    private static final int camera_capture_image_request_code = 100;    public static final int media_type_image = 1;    private uri fileuri;   private button btncapturepicture;   public static string extra_message_id;   public static string extra_message_scan;   string message_id;   string message_scan;    @override   protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      getactionbar().setbackgrounddrawable(new colordrawable(color.parsecolor(getresources().getstring(r.color.action_bar))));     intent intent = getintent();     message_id = intent.getstringextra(selectactivity.extra_message_id);     message_scan = intent.getstringextra(selectactivity.extra_message_scan);      log.e("log_tag", "id"+message_id);     log.e("log_tag", "scan"+message_scan);      btncapturepicture = (button) findviewbyid(r.id.btncapturepicture);    /**     * capture image button click event     */     btncapturepicture.setonclicklistener(new view.onclicklistener() {       @override       public void onclick(view v) {         captureimage();       }     });   } } 

the logcat looks this:

04-01 10:57:43.671: e/log_tag(12649): connection success  04-01 10:57:50.374: e/log_tag(12649): sel id1 04-01 10:57:50.374: e/log_tag(12649): sel scan2 04-01 10:57:50.403: e/log_tag(12649): id1 04-01 10:57:50.403: e/log_tag(12649): scan1 

you should try this:

change in selectactivity:

 public static string extra_message_id="extramsgid";  public static string extra_message_scan="extramsgscan"; 

should not this. if give

public static string extra_message_id; public static string extra_message_scan; 

this empty string.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -