I have an Activity A (Splash Activity), Activity B (Home Activity), Activity C(Offers Activity), Activity D (Miscellaneous Activity). I want to create appropriate Landings to Offers Activity in two scenarios:
General App flow: Activity A-> Activity B -> Activity C-> Activity D
Scenario A: When the application is closed. (Not exist in the task manager) Requirement: On Clicking the Push Notification, I want the user should land directly to Activity C (Offers Activity). And I want that on clicking back button the user should not exit from the application, rather he should be able to see Activity A and then clicking back from A, he should exit. Current Scenario: Right now, when notification lands,on clicking to it, user land to Activity C (that is right), but on clicking back from that screen, the user directly exits from the application. Why this is so ? Here is my parentactivity stack code
<activity
android:name=".OffersActivity"
android:screenOrientation="portrait"
android:theme="@style/AppTheme"
android:windowSoftInputMode="stateHidden">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.zotopay.zoto.HomeActivity" />
</activity>
<activity
android:name=".HomeActivity"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan"
android:theme="@style/AppTheme"
>
</activity>
defaultConfig {
applicationId "com.zotopay.zoto"
minSdkVersion 14
targetSdkVersion 22
versionCode 1310145
versionName "1.4.5"
}
Push Notification Landing Code:
Intent resultIntent = new Intent(this, OffersActivity.class);
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this);
// All the parents of OffersActivity will be added to task stack.
stackBuilder.addParentStack(OffersActivity.class);
// Add a SecondActivity intent to the task stack.
stackBuilder.addNextIntent(resultIntent);
PendingIntent contentIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
Can anyone please let me know what I am doing wrong? because of which I get exited from the application when press back from the Offers Activity rather than landing to HomeActivity.