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:-
onClick()
of the button in App-2 has the following code:-
Intent i = new Intent(); i.setAction("com.xyz"); //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>
FLAG_ACTIVITY_NEW_TASK informs Android to start a new task; the new task doesn't contain B & C, so don't expect any of them to be shown. Also, FLAG_ACTIVITY_CLEAR_TOP removes B & C, which is exactly opposite to what you want.
Try removing both flags.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.