views:

119

answers:

0

I have two applications App-1 & App-2. App-2 has a button which will start App-1.

The need is to behave like the following:-

  1. User launches App-1 (using launcher) & activities A, B & C are started & activity C is at the top of the activity stack.
  2. Please note that entry point of App-1 is activity A.
  3. User presses home key.
  4. User then launches the application App-2. User chooses the button in App-2 to start App-1.
  5. onClick() of the button in App-2 has the following code:- Intent i = new Intent(); i.setAction("com.x.y.z"); //resolves to activity A of App-1 i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); i.putExtra("x", "y"); startActivity(i);

After step-4, onCreate() of activity A is called which is quite normal. But i want Android to bring the entire Activity Stack to be brought to the foreground, since App-1 is running & Android hasn't killed it.(Which is the same behavior if i had launched App-1 after step-2).

I want activity C to be shown to the user.

Kindly help me if it is possible to do this.

I have tried making activity A as singleTask & singleInstance. if i do that, only activity A is brought to the foreground which is not what i want.

the snippet of App-1's manifest looks like below:-

<activity android:name=".aa.a"

         android:configChanges="orientation|keyboardHidden|locale"
         android:label="@string/app_name"
         android:theme="@android:style/Theme.NoDisplay"
         >
            <intent-filter>
             <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.DEFAULT" />
           </intent-filter>
           <intent-filter>
                 <action android:name="com.x.y.z" />
                 <category android:name="android.intent.category.LAUNCHER" />
                 <category android:name="android.intent.category.DEFAULT" />
             </intent-filter>

</activity>