从服务启动对话框 [英] Launching Dialog from Service

查看:25
本文介绍了从服务启动对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从悬停在用户当前正在查看的任何内容上的服务启动一个对话框.对话框像这样启动:服务被触发以打开对话框 > 启动透明活动 > 透明活动显示对话框.

I want to launch a dialog from a service that hovers over whatever the user is currently looking at. The dialog gets launched like this: service gets trigger to open dialog > start transparent activity > transparent activity shows dialog.

我的问题是当用户打开应用程序,启动到主菜单,然后按 HOME 离开时.通过按 HOME,它使主菜单活动处于暂停状态,而不是被破坏,当服务启动对话框时,主菜单显示在透明活动下方;导致对话框失去将鼠标悬停在用户正在查看的内容上的效果.

My problem is when the user opens the app, launches into the main menu, and then presses HOME to leave. By pressing HOME, it leaves the main menu activity on pause, not destroyed, and when the service starts the dialog, the main menu gets shown underneath the transparent activity; causing the dialog to loose the affect of hovering over whatever the user is looking at.

如何才能使透明活动独立于应用程序中的任何其他活动而打开?目前防止这种情况的唯一方法是在暂停时完成所有活动;但这是不切实际的.

How can make it so that the transparent activity gets opened independently of any other activities in the app? The only way to prevent this currently is to finish all the activities when they are paused; but this is impractical.

推荐答案

我自己发现了这个,只需在启动 Intent 中添加 Intent.FLAG_ACTIVITY_MULTIPLE_TASK 标志;当然结合 Intent.FLAG_ACTIVITY_NEW_TASK 标志.

Found this out myself, just add the Intent.FLAG_ACTIVITY_MULTIPLE_TASK flag to the launch Intent; of course in conjunction with the Intent.FLAG_ACTIVITY_NEW_TASK flag.

这篇关于从服务启动对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆