Androidでローカル通知を実装していて、Android 6.0(Samsung S7)に表示されないという問題があります。 解決策を探していましたが、この問題のために何かを見つけることはできません。Androidの通知がAndroid 6.0(Marshmallow)で動作しない
Context acontext = getApplicationContext();
PackageManager pm = acontext.getPackageManager();
Intent notificationIntent = pm.getLaunchIntentForPackage(acontext.getPackageName());
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(acontext, 0, notificationIntent, 0);
int notification_icon = acontext.getResources().getIdentifier("icon", "drawable", acontext.getPackageName());
int notificationID = 0;
// Build notification
Notification noti = new Notification.Builder(acontext)
.setContentTitle("Title")
.setContentText("Incoming text")
.setSmallIcon(notification_icon)
.setContentIntent(pendingIntent)
.setLights(Color.RED, 1, 1)
.build();
NotificationManager notificationManager = (NotificationManager) acontext.getSystemService(Context.NOTIFICATION_SERVICE);
// hide the notification after its selected
noti.sound = Uri.parse("android.resource://" + acontext.getPackageName() + "/raw/incoming");
noti.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(notificationID, noti);
でした誰:私も、私は通知のタイトル、テキスト、着信音(生フォルダ)に定義されている、適切な解像度/描画可能なフォルダのアイコンを持っていますが、それは現れていない... は私のコードがありますそうでなければこの問題が発生しますか?どんな助けもありがとう。ありがとうございました。
通知は下位バージョンで機能していますか? –
はい、Android 5.0で動作しています –
ロガーにメッセージが表示されますか? –