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