Saturday, October 24, 2009

Use mp3 as Notification sound

In the perviouse article, Status Bar Notifications, Notification is displayed on Status Bar.

To use the user's default sound, add "DEFAULT_SOUND" to the defaults field:

notification.defaults |= Notification.DEFAULT_SOUND;

But...actually, I can't make my Emulator to have any sound using this method. May be there are some setting missed in my Emulator.
(If you know why, please leave me a comment to let me know, thx.)

Alternatively, I use a mp3 file in sdcard as Notification sound.

- Follow my previous articles to Create an SD Card to existing AVD, and Copying Files to a Disk Image, to copy a mp3 file to the root of the sdcard, named sound.card.

- Add the code in the Activity.

notification.sound = Uri.parse("file:///sdcard/sound.mp3");

No comments: