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
Android - Multi-Line Linear Layout
How to Get References for All Currently Active Fragments in an Activity
Android: How to Get a List of All Available Intent Filters
Xiaomi Does Not Receive Notification When Application Is Not Running
How to Get HTML Source Code from Url in Android
Change Text Color of Selected Item in Spinner
How to Disable Home Button in Android
How to Use Fragments in Android
Sms Manager Send Mutlipart Message When There Is Less Than 160 Characters
Android Simplecursoradapter Doesn't Update When Database Changes
Set Font for All Textviews in Activity
Android:How to Update the Selector(Statelistdrawable) Programmatically
Start a Fragment via Intent Within a Fragment
Exif Orientation Tag Value Always 0 for Image Taken with Portrait Camera App Android
Android Device as a Receiver for A2Dp Profile