アプリを終了した後、アンドロイド通知が消える:/なぜですか?私は、この通知を作成するアプリケーションを閉じた後ではなく、それをクリックした後に消える永続的な通知を作成したいと思います。誰かが助けることができますか?アプリの終了後にアンドロイド通知が消える
MainActivityクラス:
private void createNotification() {
Intent intent = new Intent(this, eTutorActivity.class);
PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0);
Bitmap icon = BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher);
Notification noti = new NotificationCompat.Builder(this)
.setContentTitle("xxx")
.setContentText("xxx")
.setTicker("xxx")
.setSmallIcon(android.R.drawable.ic_dialog_info)
.setLargeIcon(icon)
.setOngoing(true)
.setAutoCancel(true)
.setContentIntent(pIntent)
.build();
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
notificationManager.notify(0, noti);
}
MainActivityクラスのonCreateアクション:
protected void onCreate(Bundle savedInstanceState) {
..
createNotification()
..
}
EDIT:
ネクサス7のAndroid 5.1は、Android 6.0を正しく
ネクサス5取り組んでいます。 1は働いているまったく同じ
Xioami Redmi注2 MIUI 7.3.2.0のAndroid 5.0.2は動作していないため、アプリケーションを終了すると通知が消えます。
あなたはどのデバイスを使用していますか、最近のリストからアプリを削除しますか? –
通知をトリガしているのは何ですか?サービス? –
Xiaomi Redmi注2、他のアプリからの通知が正しく機能します。 はい、最近のリストからアプリを削除しています。 私はサービス経由で試していましたが、今はonCreate()メソッドの主な(そして唯一の)アクティビティの中で通知をトリガーしています。どちらの場合も結果は同じです。通知は、アプリケーションを閉じる(リストから削除する)まで表示されます。 – LuckyLue