启动应用程序时收到GCM通知 [英] Launch application when GCM notification received

查看:103
本文介绍了启动应用程序时收到GCM通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有GCM通知执行。我知道,客户端应用程序收到通知,无论是在前台,后台或死亡状态。我想知道的是,我怎么可以启动我的应用程序的通知接收,当应用程序处于灭活状态?

I have GCM notification implementation. I know that the client application receives the notification whether it is in the foreground, background or killed state. What I would like to know is, how can I launch my application on notification received, when the application is in the killed state?

推荐答案

在消息接收器,我执行以下操作:

In the message receiver, I do the following:

final Intent notificationIntent = new Intent(context, YourActivity.class);
notificationIntent.setAction(Intent.ACTION_MAIN);
notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER);

下面的条目活动取代YourActivity.class。这为我工作。

Here replace YourActivity.class with the entry activity. This worked for me.

这篇关于启动应用程序时收到GCM通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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