Android-通过将已经运行的进程发送到后台来从服务启动活动
我有一个后台服务 BGService
,它在发生某些事件时显示一个 Activity BGServActivity
。我已经重写 onBackPressed 来完成显示的 Activity BGServActivity
。
假设当前正在显示应用程序 App_XYZ
的 UI。我的服务 BGService
由事件触发并显示 BGServActivity
。当我按下回键时,它会关闭当前的 Activity BGServActivity
并显示应用程序 App_XYZ
中的先前 UI。
但我希望当我从 BGService
启动 BGServActivity
时,将 App_XYZ
中的 UI 发送到后台。
我的问题是
在从我的服务启动我的
。BGServActivity
之前,是否有任何特殊标志或我可以做的事情来将之前显示的UI从另一个活动发送到后台>BG服务
I have a background service BGService
, it displays an Activity BGServActivity
when certain event occurs. I have override onBackPressed to finish the displayed Activity BGServActivity
.
Suppose, UI of Application App_XYZ
is currently displaying. And my service BGService
is triggered by the event and BGServActivity
is displayed. And When i press back it closes the current Activity BGServActivity
and displays the previous UI from Application App_XYZ
.
But i want the UI from App_XYZ
to be sent to background when i start BGServActivity
from my BGService
.
My question is
Is there any special flag or something that i can do to send the previously displaying UI from another activity to sent to background before starting My BGServActivity
from My service BGService
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想在“活动”关闭时强制用户转到主屏幕,您可以这样做:
不过我建议不要这样做。关闭活动时的标准行为应该是返回到之前查看的活动。
If you want to force the user to go to the Home screen when your Activity closes, you can do this:
I advise against this though. The standard behavior when closing an activity should be to return to the previously viewed activity.
我想我找到了解决方案。
首先将主屏幕显示为 goto10 的解决方案
然后打开我的 Activity
BGServActivity
及其工作...:D
I think i got solution.
First show the HOME Screen as goto10's solution
Then-after open my Activity
BGServActivity
And its working... :D