使Android通知呆到用户将其清除 [英] make android notification stay until user clears it
问题描述
我的问题是关于通知和 NotificationManager
,
在我的应用我用一个通知提醒用户,却一次次我给它只有一次的MP3和振动唯一的,我希望它播放声音和振动,直到用户通过pressing清晰明确的通知。我无法找到它简化的例子,什么是实现,最好的方法是什么?
My question is regarding Notification and NotificationManager
,
in my app I use a Notification to alert the user, but it plays the mp3 I gave it only once, and vibrates only ones, I wish it to play a sound and vibrate until the user clear the Notification by pressing clear. I couldn't find an example that simplified it, what's the best way to achieve that?
感谢所有的回复,
Amitos80
Thank All that reply, Amitos80
推荐答案
有可以实现预期的效果设置的标志,
there are flags you can set for achieving desired result,
Notification notification = new Notification(mIcon, mTickerText, mWhen);
notification.setLatestEventInfo(mContext, mContentTitle, mContentText, mContentIntent);
notification.defaults |= Notification.DEFAULT_SOUND;
notification.flags = Notification.FLAG_AUTO_CANCEL;
mNotificationManager.notify(ID, notification);
这肯定会工作。
如果你觉得它有用不要忘记将其标记为一个答案。
If you find it useful dont forget to mark it as an answer.
这篇关于使Android通知呆到用户将其清除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!