Android - Build a notification, TaskStackBuilder.addParentStack not working

前端 未结 11 2610
说谎
说谎 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条回答
  •  -上瘾入骨i
    2020-11-28 06:26

    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+):

    
    

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

    
        
    
    

提交回复
热议问题