点击GCM通知后打开活动 [英] Open activity when GCM notification was clicked

查看:106
本文介绍了点击GCM通知后打开活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个gcm应用程序,现在我可以收到通知



但是当我点击通知时,它只是打开应用程序。



我需要打开另一个活动而不是主要活动

有没有办法做到这一点?

解决方案

  final Intent intent = new Intent(context,YourActivity.class); 
intent.putExtra(key,value);
final PendingIntent pendingIntent = PendingIntent.getActivity(this,0,intent,0);
final NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.set ...;
final NotificationManager notificationManager =(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID,builder.build());


I'm making a gcm application, and now I can receive the notification

But when I click the notification, it just open the app.

I need to open another activity instead of Mainactivity

is there any way to do this?

解决方案

final Intent intent = new Intent(context, YourActivity.class);
intent.putExtra("key", "value");
final PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);
final NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.set...;
final NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(NOTIFICATION_ID, builder.build());

这篇关于点击GCM通知后打开活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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