2
我試圖通過下面的代碼進行擡頭通知,並希望它在用戶決定解僱它之前保持不變。但幾秒鐘後(約10秒)就會自動解散。有沒有什麼辦法讓它持久化並留給用戶來解僱它。Heads Up幾秒後得到解僱的通知
NotificationCompat.Builder builder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("Notification")
.setContentText("Hello !!!")
.setDefaults(Notification.DEFAULT_ALL)
.setPriority(NotificationCompat.PRIORITY_HIGH)
.addAction(R.drawable.ic_launcher,
"View Call", null)
.addAction(R.drawable.ic_launcher,
"Call Back", null);
// Gets an instance of the NotificationManager service
NotificationManager notificationManager =
(NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0, builder.build());
「但它會在幾秒鐘後(約10秒)自動解除」 - 如果通過「解僱」,你的意思是它變成了一個正常的「通知」狀態欄中的圖標,是預期的行爲。 – CommonsWare
是的,它變成了正常的通知 – kaddy
嘗試使用setAutoCancel(false) – Mahamadali