Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use notification with sound and vibration?

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?

like image 267
yoshi24 Avatar asked Aug 30 '11 03:08

yoshi24


People also ask

How do I separate ringtone and notification volume Android?

The ringtone and notification sound volume can't be adjust separately as the Android operating system uses a single volume control for both. If you've increased the ringtone volume and the notification sound seems too loud for you, consider muting the notification sound. To mute the notification sound: Go to Settings.

Why does my phone not vibrate from notifications?

If Vibration is turned off in Accessibility settings, your iPhone won't vibrate even if the vibration motor is fully functional. Go to Settings -> Accessibility -> Touch and make sure the switch next to Vibration is turned on.


1 Answers

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; 

That adds sound and 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.

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

like image 64
Reed Avatar answered Sep 18 '22 14:09

Reed