从PUSH通知打开Android应用程序

Pin*_*cks 9 android push-notification urbanairship.com android-pendingintent

有一点问题一直困扰着我..

我已经设置了我的应用程序来接收来自Urban Airship的PUSH通知,并且一切正常,但是当我点击通知中心的通知时,没有任何反应.

当用户点击PUSH通知时,我希望我的应用程序打开 - 我该怎么做才能实现这一目标?

任何帮助总是非常感激.

谢谢

San*_*San 10

创建挂起的Intent以启动活动,并使用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);
Run Code Online (Sandbox Code Playgroud)

更多信息可以在这里找到