I start the operation - who has parental activity - from the notification in the notification box. The activity of the child is activated. I want the child activity to return to the parent activity when the navigation button up is pressed. This behavior works for a normal application flow. However, when a user enters a child activity through a notification, pressing the up navigation button does not lead the user to parent activity; instead, it terminates the application.
Here is the manifest for the activity that should be triggered when the notification is clicked. It has parent TabbedActivity
<activity android:name=".activity.AnimalDetailsActivity" android:parentActivityName=".activity.TabbedActivity" > <meta-data android:name="android.support.PARENT_ACTIVITY" android:value=".activity.TabbedActivity"/> </activity>
Here I create a notice and intent:
Intent resultIntent = new Intent(context.getApplicationContext(), AnimalDetailsActivity.class); TaskStackBuilder stackBuilder = TaskStackBuilder.create(context.getApplicationContext()); stackBuilder.addParentStack(AnimalDetailsActivity.class); stackBuilder.addNextIntent(resultIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(context) .setSmallIcon(icon_resource_id) .setLargeIcon(large_icon) .setContentTitle(title) .setContentText(text) .setContentIntent(resultPendingIntent) .setAutoCancel(true); return builder.build();
And then send them
private static void sendNotifications(List<android.app.Notification> notifications) { NotificationManager manager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); for (android.app.Notification notification : notifications) { manager.notify(++drawerId, notification); } }
Inside the target action, I include the up and up arrow navigation:
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getActionBar().setHomeButtonEnabled(true); getActionBar().setDisplayHomeAsUpEnabled(true);
I believe that I follow the instructions correctly. So why doesn't the up arrow lead the user to parent activity?
source share