Android - Build a notification, TaskStackBuilder.addParentStack not working

前端 未结 11 2640
说谎
说谎 2020-11-28 06:23

I\'m trying to launch an activity from a notification like the Android docs explain, but when I open the notification and then press the back button, the HomeActivity (paren

11条回答
  •  天涯浪人
    2020-11-28 06:42

    Intent resultIntent = new Intent(App.getContext(), TargetActivity.class);
    Intent backIntent = new Intent(App.getContext(), ParentActivity.class);
    backIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
    final PendingIntent resultPendingIntent = PendingIntent.getActivities(
                                        App.getContext(), 0, 
                   new Intent[]{backIntent, resultIntent}, PendingIntent.FLAG_ONE_SHOT);
    mNotifyBuilder.setContentIntent(resultPendingIntent);
    

    this solved my problem with Parent stack on Notification Click

提交回复
热议问题