7

I don't know how to tackle this Android issue. In few words, the flow between my 2 applications is as below :

Flow

  1. Bind Application A to a service in Market application (AIDL)
  2. Register a BroadcastReceiver and call a service method that returns a pendingIntent.
  3. Launch PendingIntent (contains BillingActivity instance).
  4. Start PaymentActivity with "startActivityForResult()".
  5. Do some stuffs, terminate (finish() ).
  6. in onActivitiyResult() method, send a Broadcast and terminate.
  7. Get Broadcast informations.

Flow between my 2 applications

Issue :

I want to create a task with the below components :

  • Top1Activity(Application A)
  • BillingActivity (Market Application)
  • PaymentActivity (Market Application)

foreground and background tasks for Android

I tried to change the BillingActivity + PaymentActivity "launchMode" :

singleInstance

A new task is created for both of them. When pressing return button (or calling finish() method), user is redirected as expected to the previous activity. Problem: "StartActivityForResult" cannot be use between multiple tasks (onActivityResult is called immediately ).

SingleTask

When pressing return button (or calling finish() method) in BillingActivity, user is redirected to the Top2Activity (which was in the background task).

I 've lost more than 48 hours trying to solve it. I would appreciate your help. I can post code if needed.

Thank you

----------- EDIT 2015-02-02

Following the advice of David, i removed all 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 returning 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 pressing back button from BillingActivity (or PaymentActivity), I am still redirected to the Top2Activity...

No idea ? Thank you

johann
  • 1,115
  • 8
  • 34
  • 60
  • Doesn't look like you need anything special. Remove all special launch modes. If it doesn't work as you expect, please explain what happens. – David Wasser Jan 30 '15 at 17:35
  • Thank you David. I have updated my message (adding some code). I've changed my launch modes as you told me but it didn't fix it. no idea ? thank you – johann Feb 02 '15 at 01:21
  • Please explain what is `Top2Activity` and post the manifest for that. and indicate how it got in the task. It sounds like your problem is `taskAffinity` – David Wasser Feb 02 '15 at 07:13
  • Top2Activity is the main activity(after the splash screen) for my "Market application". This is the last activity displayed before application A is launched. manifest info is available in my message. If you need more details, please let me know. thank you – johann Feb 02 '15 at 07:24

1 Answers1

2

Add android:taskAffinity="" to the <activity> defninitions for bothBillingActivityandPaymentActivity`.

David Wasser
  • 93,459
  • 16
  • 209
  • 274