android - startActivityForResult Returning Immediately when passing Intents between different Applications -


i have 2 separate android apps, applicationa , applicationb. wish open applicationa, type data edittext, , send value applicationb. in applicationb, wish perform actions , send value edittext in applicationb applicationa. currently, doing using intents:

    applicationa     ----->    applicationb        ----->        applicationb        ----->   applicationa  start mainactivity in        handle intent           perform actions,       handle intent applicaitonb, sending        applicationa, , read           start mainactivity     applicationb, , read                                               data                    intent's data                in applicationa, sending    data                                                               data 

as can see, using 1 intent to go -> b, , 1 go b -> a.

it seem easier start applicationb's mainactivity using intent applicaitona , calling startactivityforresult(), while implementing onactivityresult() in applicationa handle respone applicationb. problem seems startactivityforresult() returns immediately, there no time user in applicationb perform actions before returning data applicationa. seems work if both activities in same application, since in different applications, startactivityforresult() returning immediately.

this mainactivity class of applicationa:

@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);      setcontentview(r.layout.activity_main);      final edittext et = (edittext) this.findviewbyid(r.id.somedataina);        final button btn = (button) this.findviewbyid(r.id.button);      btn.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {             intent = mainactivity.this.getpackagemanager().getlaunchintentforpackage("com.comp.activityb");             mainactivity.this.startactivity(i);         }     }); } 

and mainactiivty class of applicationb:

in@override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);      setcontentview(r.layout.activity_main);      final edittext et = (edittext) this.findviewbyid(r.id.somedatainb);      final button btn = (button) this.findviewbyid(r.id.button);      btn.setonclicklistener(new view.onclicklistener() {         @override         public void onclick(view v) {             intent = mainactivity.this.getpackagemanager().getlaunchintentforpackage("com.comp.activitya");             mainactivity.this.startactivity(i);         }     }); } 

here androidmanifest applicationa:

 <application     android:allowbackup="true"     android:icon="@mipmap/ic_launcher"     android:label="@string/app_name"     android:theme="@style/apptheme">     <activity         android:name=".mainactivity"         android:label="@string/app_name">         <intent-filter>             <action android:name="android.intent.action.main" />             <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity> </application> 

and androidmanifest applicationb:

   <application     android:allowbackup="true"     android:icon="@mipmap/ic_launcher"     android:label="@string/app_name"     android:theme="@style/apptheme" >     <activity         android:name=".mainactivity"         android:label="@string/app_name" >         <intent-filter>             <action android:name="android.intent.action.main" />             <category android:name="android.intent.category.launcher" />         </intent-filter>     </activity> </application> 

your problem applications starting in new tasks or clearing task stack. since getting launch intent , not using intentfilter or other structure target , stack activities, startactivityforresult not useful.

you should @ (although more need):

using startactivityforresult across android applications

(you need post manifests give more insight problem.)


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -