简体   繁体   English

在收到应用程序启动器之类的通知推送后,将Android应用程序置于前台

[英]Bring the Android app to foreground after recieving a notification push like the application launcher

In my case, I receive a notification message and open an Activity say 'X'. 在我的情况下,我收到一条通知消息并打开一个活动说'X'。 After closing it I want to bring my application again to foreground like the behavior of the Application launcher. 关闭它后,我想再次将我的应用程序带到前台,就像应用程序启动器的行为一样。

In more details I want to see if my app in the background, bring it to foreground. 在更多细节中,我想看看我的应用程序是否在后台,将其带到前台。 If not, restart it. 如果没有,请重新启动它。 Any suggestions, please? 有什么建议吗?

if you need to start or open your activity when user click on Notification then just use Intent to call your main activity or home page that's it. 如果您需要在用户点击Notification时启动或打开您的活动,那么只需使用Intent来调用您的主要活动或主页。 have you Google your problem? 你有谷歌问题吗? See the documents of Notification Notification and for Intent it may helpful for you 请参阅通知通知文档,对于意图,它可能对您有所帮助

You can use getRunningAppProcesses() in ActivityManager . 您可以getRunningAppProcesses() in ActivityManager使用getRunningAppProcesses() in ActivityManager And then check your package name in the list of running Processes. 然后在正在运行的进程列表中检查您的名称。

使用C2DM - 云到设备消息来收听通知并启动您的应用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM