点击GCM通知后打开活动

编程入门 行业动态 更新时间:2024-10-23 13:26:35
本文介绍了点击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通知后打开活动

本文发布于:2023-11-27 07:14:52,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:通知   GCM

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!