Android - Build a Notification, Taskstackbuilder.Addparentstack Not Working

Android - Build a notification, TaskStackBuilder.addParentStack not working

You need to add the parent stack for the activity you're launching, not the parent of it.

Replace:

stackBuilder.addParentStack(MainActivity.class);

with:

stackBuilder.addParentStack( MatchActivity.class );

This assumes that you've defined the parent in your Manifest (API 16+):

<activity android:name=".MatchActivity"
android:parentActivityName=".MainActivity"
... />

If you're developing for under API 16, then you have to define the parent as:

<activity android:name=".MatchActivity">
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>

TaskStackBuilder not returning to MainActivity

Replace the line:

stackBuilder.addParentStack(MainActivity.class);

With:

stackBuilder.addParentStack(ResultActivity.class);

Also add the <meta-data tag to your activity in the manifest if you're testing on API level less than 16

<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity"/>

Up navigation using backstack not working while clicked from notification

Solution -

I added my child activity as well in addParentStack(MyTrialActivity.class);

And it worked as expected.
I thought adding addNextIntent() should be doing that already, though it did not work that way..



Related Topics



Leave a reply



Submit