开发者

make android notification stay until user clears it

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 t开发者_如何转开发hat?

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);

This will work definitely.

If you find it useful dont forget to mark it as an answer.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜