[英]Launching launcher activity from pending intent in notifications
如果我的启动器活动A现在正在运行。
并且一些活动在活动A之上。
例如,这是我的后台ABC
在按通知启动A,清除ABC,然后打开A,或关闭B和C并通过onNewIntent恢复A时,我需要
我尝试添加一些标志,但没有帮助!
private void push(NotificationModel model, Intent intent) {
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
//here I'm trying to add flags to my intent
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
在清单文件中使用android:launchMode="singleTop"
。
在这种启动模式下,如果活动的实例已经存在于当前任务的顶部,则不会创建新实例,Android系统将通过onNewIntent()
路由意图信息。
如果任务顶部没有实例,则将创建一个新实例。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.