从推送通知开放的Andr​​oid应用程序 [英] Open android app from PUSH notification

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

问题描述

有一个小问题一直缠着我。

Got a little problem that's been bugging me..

我已经设置了我的应用程序接收来自城市飞艇推送通知以及所有工作正常,但是当我点击在通知中心的通知,没有任何反应。

I've set up my application to receive PUSH notifications from Urban Airship and that all works fine, but when I tap on a notification in the notifications center, nothing happens.

我想我的应用程序,当用户点击一个推送通知开 - 我能做些什么来实现这一点。

I want my app to open when a user taps a PUSH notification - what can I do to achieve this?

任何帮助是一如既往大大AP preciated。

Any help is as always greatly appreciated.

感谢

推荐答案

创建一个悬而未决意图开始活动,并利用setLatestEventInfo设置它通知。

Create a pending Intent to start the activity and set it in notification using setLatestEventInfo.

例如:

  Context context = getApplicationContext();
CharSequence contentTitle = "My notification";
CharSequence contentText = "Hello World!";
Intent notificationIntent = new Intent(this, MyClass.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);

这里

更​​多信息,可以发现

More info can be found here

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

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