Search code examples
androidcordovacordova-3

How to add resources file to my phonegap project


I'am using Cordova LocalNotification-Plugin to show some notification to user . Now what I want to do is to have a specific sound on notification . They said to add this

window.plugin.notification.local.add({ sound: 'android.resource://' + package_name +/raw/beep});

Note: Local sound files must be placed into the res-folder and not into the assets-folder.

I don't know in which res folder should I put my mp3. And if I try to put it into main res folder where I have : drawable; drawable-hdpi; drawable-ldpi;drawable-mdpi;drawable-xhdpi;values;xml folders when I build the project I get this error:

invalid resource directory name: C:\Users\etc\etc\myprojectname\platforms\android\res/sounds

What should I do ?


Solution

  • As I understand it, you should put your sound file in the res/raw folder instead of res/sounds (as you see in the plugin call : +/raw/beep).

    There is no /res/sounds folder in android, datas that do not fit in other categories should be put in /res/raw. You can have a look at the sdk doc