从推送通知开放的Andr​​oid应用程序应用程序、通知、Andr、oid

由网友(不折骨风.)分享简介:有一个小问题一直缠着我。Got a little problem that's been bugging me..我已经设置了我的应用程序接收来自城市飞艇推送通知以及所有工作正常,但是当我点击在通知中心的通知,没有任何反应。I've set up my application to receive PUSH no...

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

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

阅读全文

相关推荐

最新文章