Android深层链接嵌套活动返回栈无法正常工作。
创始人
2024-10-10 11:00:44
0次

可以使用TaskStackBuilder类构建正确的返回栈,以便在深层链接嵌套活动时能够正常工作。以下是示例代码:

Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("myapp://home"));

// Intent representing the destination screen for the link
Intent deepLinkIntent = new Intent(this, DeepLinkActivity.class);

// Use TaskStackBuilder to build the back stack
TaskStackBuilder stackBuilder = TaskStackBuilder.create(this)
    .addParentStack(MainActivity.class)
    .addNextIntent(intent)
    .addNextIntent(deepLinkIntent);

// Get the PendingIntent containing the back stack
PendingIntent pendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);

// Set the content intent of the notification
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
    .setContentIntent(pendingIntent)
    .setSmallIcon(R.drawable.ic_notification)
    .setContentTitle("My App")
    .setContentText("New content available");

// Issue the notification
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
notificationManager.notify(0, builder.build());

通过使用TaskStackBuilder类和addParentStack()方法构建正确的返回栈,即可实现深层链接嵌套活动的返回功能。

相关内容

热门资讯

黑科技外挂!微乐自建房脚本免费... 黑科技外挂!微乐自建房脚本免费入口(外挂),微乐联盟其实有透视挂插件暗藏猫腻,小编详细说明微乐自建房...
黑科技作弊器!微乐小程序自建房... 黑科技作弊器!微乐小程序自建房辅助器(作弊器),微乐小程序微乐系列本来真的有透视挂工具1、完成微乐小...
黑科技透视挂!微乐辅助工具哪个... 黑科技透视挂!微乐辅助工具哪个好用(透视挂),微乐海南麻将总是是有透视挂脚本1、该软件可以轻松地帮助...
黑科技外挂!微信小程序微乐破解... 黑科技外挂!微信小程序微乐破解器(外挂),微乐浙江麻将确实是真的有透视挂方法1、上手简单,内置详细流...
黑科技辅助!微乐建房辅助工具免... 黑科技辅助!微乐建房辅助工具免费入口(辅助),微乐吉林麻将本来有透视挂软件1、微乐建房辅助工具免费入...
黑科技开挂!小程序微乐陕西挖坑... 黑科技开挂!小程序微乐陕西挖坑辅助(开挂),微乐鞍山麻将切实真的是有透视挂攻略小程序微乐陕西挖坑辅助...
黑科技开挂!微乐游戏小程序脚本... 黑科技开挂!微乐游戏小程序脚本(开挂),微乐斗地主填大坑竟然是真的有透视挂方法1、微乐游戏小程序脚本...
黑科技开挂!微乐小程序黑科技免... 黑科技开挂!微乐小程序黑科技免费(开挂),微乐云南麻将切实真的有透视挂技巧1、超多福利:超高返利,海...
黑科技辅助!微乐自建房安装挂免... 黑科技辅助!微乐自建房安装挂免费(辅助),微乐郑州麻将其实有透视挂攻略在进入微乐自建房安装挂免费软件...
黑科技辅助!微乐广西小程序开挂... 黑科技辅助!微乐广西小程序开挂(辅助),微乐辅助神器好像真的是有透视挂教程一、微乐广西小程序开挂游戏...