2
我遇到了一些问题。我有一个AlarmManager向BroadcastReceiver发送意图,在该类的onReceive
方法中,我将通知推送到StatusBar ...这很像一个魅力,但我需要在用户点击通知时打开一个活动,但在谷歌上搜索,并在这样我无法找到答案后寻找我的代码的一些问题......所以这是我的代码推通知符:打开BroadcastReceiver发送的通知时打开活动
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setClass(this.context, NewCommit.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent sender = PendingIntent.getBroadcast(this.context, 192839, intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder noti = new NotificationCompat.Builder(this.context)
.setSmallIcon(R.drawable.status_bar_icon)
.setContentTitle("My notification")
.setContentText("Hello World!")
.setContentIntent(sender);
noti.setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE);
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
mNotificationManager.notify(181818, noti.build());
任何想法?这让我疯狂!
谢谢!
感谢兄弟!您是对的!我花了数小时试图弄清楚这一点! ! 谢谢!! – Andres 2013-02-22 00:40:11