如何知道我的应用程序是开放的,当我设法推送通知 [英] How to know if my app is open when I managed a push-notification

查看:242
本文介绍了如何知道我的应用程序是开放的,当我设法推送通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

采用Android,当我收到通知推送把我GCMIntentService,我想知道,如果我的应用程序的开放与否,因为如果我的应用程序是开放的,当用户点击我想做什么都没有通知,但如果应用程序是接近我想要打开的应用程序。

Using Android, when I received a notification push throw my GCMIntentService, I want to know if my app is open or not, because if my app is open when the user click on the notification I want to do nothing, but if the app is close I want to open the app.

推荐答案

启动根系活力(一个具有ACTION = MAIN和类别= LAUNCHER在清单),并添加 Intent.FLAG_ACTIVITY_NEW_TASK 。如果应用程序已经处于活动状态(无论哪个活动是顶部),这将只是把任务前面。如果应用程序未激活,它会启动它与您的根系活力。

Launch the root activity (the one that has ACTION=MAIN and CATEGORY=LAUNCHER in the manifest) and add Intent.FLAG_ACTIVITY_NEW_TASK. If the app is already active (no matter which activity is on top) this will just bring the task to the front. If the app isn't active, it will start it with your root activity.

这篇关于如何知道我的应用程序是开放的,当我设法推送通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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