Darko Petkovski Darko Petkovski - 1 year ago 169
Android Question

Android notifications play sound from assets folder

I'm trying to play notifications sound from the assets folder, but when notification triggers the notification is shown but no sound is played and there is no error or warning in the logCat. I'm using this code for creating notifications:

builder = new NotificationCompat.Builder(context)
// Set Icon
// Set Ticker Message
// Set Title
// Set Text
// Add an Action Button below Notification
context.getString(R.string.share), pendingShare)
// Set PendingIntent into Notification
// Dismiss Notification
+ prefs.getString(Constants.NOTIF_SOUND,

can someone help me solve this issue?

Answer Source

Put your mp3 file under raw folder. If you put it under asset/ it's going to be compressed twice and you can't use it.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download