I do not know how to solve this problem with Android. In a few words, the flow between my 2 applications is as follows:
Flow
- Bind Appendix A to the Service in the Market Attachment (AIDL)
- Register BroadcastReceiver and call the service method, which returns pendingIntent .
- Launch PendingIntent (contains an instance of BillingActivity).
- Start PaymentActivity with startActivityForResult () ".
- Do some things, complete (finish ()).
- in onActivitiyResult () , send the broadcast and complete.
- Get broadcast information .

Problem:
I want to create a task using the following components:
- Top1Activity (Application A)
- BillingActivity (market app)
- PaymentActivity (Market Application)

I tried changing BillingActivity + PaymentActivity "launchMode":
Singleinstance
A new task is being created for them. When you press the return button (or call the finish () method), the user is redirected, as expected, to the previous operation. Problem: "StartActivityForResult" cannot be used between multiple tasks (onActivityResult is called immediately).
Singletask
When you click the return button (or call the finish () method) in BillingActivity, the user is redirected to Top2Activity (which was in the background job).
I lost over 48 hours trying to solve it. I would be grateful for your help. If necessary, I can send the code.
thanks
----------- EDIT 2015-02-02
Following David's advice, I removed all of the special launch modes:
TOP2Activity (background):
<activity android:name=".activities.MainActivity" android:configChanges="orientation|keyboardHidden" android:label="@string/title_activity_main" android:screenOrientation="portrait" android:windowSoftInputMode="stateAlwaysHidden|adjustPan" > <meta-data android:name="android.app.searchable" android:resource="@xml/searchable" /> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="xxx" /> <data android:host="xxx" /> </intent-filter> </activity>
My Top1Activity (Foreground):
<activity android:name="activities.MainActivity" android:label="@string/app_name" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity>
BillingActivity (foreground):
<activity android:name=".activities.BillingActivity" android:configChanges="orientation|keyboardHidden" android:excludeFromRecents="true" android:label="@string/title_activity_billing" android:screenOrientation="portrait" > <intent-filter> <action android:name="android.intent.action.VIEW" /> </intent-filter> </activity>
PaymentActivity:
<activity android:name=".activities.PaymentActivity" android:configChanges="orientation|keyboardHidden" android:label="@string/title_activity_payment" android:screenOrientation="portrait" android:windowSoftInputMode="stateHidden" > </activity>
AIDL service returns pendingIntent:
Intent intent = new Intent(); intent.setClass(InBillingService.this, jp.xxx.activities.BillingActivity.class); intent.putExtra(Consts.PENDING_INTENT_INFO, result); intent.putExtra(Consts.RESULT_KEY, nextSession); PendingIntent pendingIntent; pendingIntent = PendingIntent.getActivity(InBillingService.this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); bundle.putParcelable(Consts.PENDING_INTENT, pendingIntent);
When I click the BillingActivity (or PaymentActivity), button , I'm still redirected to Top2Activity ...
I do not know? Thanks you