Android 服务将一个活动的多个实例放入历史记录中
我正在制作一个音乐播放器。当您按下播放时,它会将通知加载到“正在进行”部分。当您转到系统中的其他任何地方时,我希望音乐继续播放。这一切都很好。
问题是,当我从通知重新启动我的活动时,它每次都会向历史堆栈添加一个任务,所以如果我回击,我必须从我按下播放的位置看到活动 B 的实例,并且每次我单击通知返回到活动 B。
我希望从通知(通过服务)启动的活动 B 的实例成为历史记录中该活动的唯一副本。我一直在清单中尝试各种意图标志和活动属性,但我还没有找到正确的组合。
I'm making a music player. When you press play, it loads a notification into the OnGoing section. When you go anywhere else in the system, I want the music to keep playing. All of this is fine.
The problem is that when I relaunch my activity from the Notification, it adds a task to the history stack each time, so if I hit back, I have to see the instance of Activity B from where I pressed play, and from every time I clicked on the notification to go back to Activity B.
I want the instance of Activity B that I launch from the notification (via the service) to be the only copy of that Activity in the history. I've been playing around with various Intent flags and Activity attributes in the manifest, but I haven't found the proper combination.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用:(
调用您与
Notification
的PendingIntent
一起使用的Intent
)Use:
(called on your
Intent
you are using with yourPendingIntent
for yourNotification
)