少し問題があります。BroadcastReceiverにインテントを送信するAlarmManagerがあり、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());
何か案が??それは私を夢中にさせています!
ありがとう!