本文介绍了点击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通知后打开活动
发布评论