android - Passing data from one app to another app using onActivityResult -


i'm trying pass data 1 app app using onactivityresult. passing data 'a' 'b' ok. when try return string b a, data.getextras() returns null ... in advance

my code:

in app a:

public void initappb(context context, string packagename, string codcli){     intent intent = context.getpackagemanager().getlaunchintentforpackage(packagename);     if (intent == null) {         intent = new intent(intent.action_view);         intent.setdata(uri.parse("market://details?id=" + packagename));     }     intent.addflags(intent.flag_activity_new_task);     intent.putextra("codcli",codcli);     startactivityforresult(intent, 123456); }  protected void onactivityresult(int requestcode, int resultcode, intent data) {     string reg = "";     if(requestcode == 123456) {       if(resultcode == -1) {         try{             bundle mbuddle = data.getextras(); // >> return null <<             reg = mbuddle.getstring("retorno");         }catch(exception e){             log("error: " + e.getmessage());         }         commitsale(reg);       } else {         // error       }     } } 

in app b:

.... //it's ok!! receiving data! bundle extras = getintent().getextras(); if (extras != null) {     codcli = extras.getstring("codcli"); }  ....  onclicklistener mbacklistener = new onclicklistener() {     public void onclick(view v) {         string registro = "010000";         intent intent = getintent();         intent.putextra("retorno",registro);         setresult(-1, intent); // --> forcing returning code -1 (ok)         finish();     } }; 

try this: in b:

intent intent = getintent(); intent.putextra("date",dateselected); setresult(result_ok, intent); finish(); 

and, in a:

@override protected void onactivityresult(int requestcode, int resultcode, intent data) {     if(resultcode==result_ok && requestcode==1) {         bundle mbundle = data.getextras();         string mmessage = mbundle.getstring("date");     } } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -