如何使用的通知声音和振动?如何使用、声音、通知

由网友(我没在等)分享简介:你如何让设备振动或发出声音时,通知将启动。 How do you allow the device to vibrate or make a sound when a notification is launched. 香港专业教育学院听到的标志。但如何将我使用他们的声音和振动?Ive heard of the...

你如何让设备振动或发出声音时,通知将启动。

How do you allow the device to vibrate or make a sound when a notification is launched.

香港专业教育学院听到的标志。但如何将我使用他们的声音和振动?

Ive heard of the FLAGS. But how would i use them for Sound and Vibration?

推荐答案

修改在Android的V4支持库,有NotificationCompat.Builder该方法 setSound 如果使用类,而不是将工作。但是,下面的信息仍然有效。

Edit In Android v4 support library, there is NotificationCompat.Builder and the method setSound which will work if using that class instead. However, the info below will still work.

Notification notif ... //create your notification

notif.defaults |= Notification.DEFAULT_SOUND;
notif.defaults |= Notification.DEFAULT_VIBRATE;

这增加了声音和振动。

永远记得检查文档。他们回答,像这样的很多:

Always remember to check the docs. They have a LOT of answers, such as this one:

http://developer.android.com/guide/topics/ui/notifiers/notifications.html

这有信息,我张贴以上,以及如何使用自定义声音或振动信息,并创建一个通知的整个过程。

That has the info I posted above as well as info on how to use a custom sound or vibrate and also the entire process of creating a notification.

编辑:不要忘了包括振动允许在你的清单。

Don't forget to include the Vibrate permission in your manifest.

阅读全文

相关推荐

最新文章