我有一个小问题。我有一个 AlarmManager,它向 BroadcastReceiver 发送意图,在onReceive
该类的方法中,我将通知推送到 StatusBar ...这就像一个魅力,但是当用户点击通知时我需要打开一个活动,但是在我的代码中存在一些问题,在谷歌搜索和搜索之后我找不到答案......所以这是我推送通知的代码:
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());
任何的想法??这让我疯狂!
谢谢!