只是一個簡單的問題:如何使單線通知在短時間後消失。狀態欄上顯示單行通知?
就像WhatsApp的公司:
我當前的通知代碼仍然是很基本的:
Intent intent = new Intent("com.example.MyChat");
PendingIntent pIntent = PendingIntent.getActivity(context, 0, intent, 0);
Notification notification = new Notification.Builder(context)
.setContentTitle("New message from " + name)
.setContentText(message)
.setSmallIcon(R.drawable.ic_launcher).setContentIntent(pIntent)
.getNotification();
notification.defaults |= Notification.DEFAULT_SOUND;
NotificationManager notificationManager = (NotificationManager) context
.getSystemService(context.NOTIFICATION_SERVICE);
notificationManager.notify(0, notification);
感謝
謝謝,很難在Google中搜索此內容,因爲我不知道正確的字詞 – hrsetyono