0

I copied the .mp3 file in assets. When notification raises, file is not playing

Could anyone please help me.

notification.sound = Uri.parse("file:///android_assets/alarm_951.mp3");
G M Ramesh
  • 3,420
  • 9
  • 37
  • 53
user1065434
  • 711
  • 1
  • 6
  • 10

2 Answers2

0

try the following:

   notifyDetails.flags = Notification.FLAG_ONLY_ALERT_ONCE | Notification.FLAG_SHOW_LIGHTS | Notification.FLAG_AUTO_CANCEL;
G M Ramesh
  • 3,420
  • 9
  • 37
  • 53
0

Instead of copying your file to the assets folder copy it to resources/raw/ and then use

Uri sound = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.mysound);
mBuilder.setSound(sound);
adrzip
  • 46
  • 1
  • 7