13

I did everything as the official docs describes. But when I navigate backwards, the MainActivity(parent) doesn't open. Instead, the application closes.

here is my code:

Intent resultIntent = new Intent(context, TestActivity.class);

TaskStackBuilder stackBuilder = TaskStackBuilder.create(context);
stackBuilder.addParentStack(TestActivity.class);
stackBuilder.addNextIntent(resultIntent);

the manifest is as below:

<activity
    android:name=".MainActivity"
    android:label="@string/app_name"
    android:theme="@style/AppTheme.NoActionBar">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>

<activity
    android:name=".TestActivity"
    android:parentActivityName=".MainActivity">
    <meta-data
        android:name="android.support.PARENT_ACTIVITY"
        android:value=".Main2Activity" />
</activity>
Oli
  • 9,766
  • 5
  • 25
  • 46
Allen Vork
  • 1,536
  • 3
  • 16
  • 29

0 Answers0