bobeast/PushPlugin-deprecated — pull request #5 by nomos (2014-01-16 09:33:08+00:00)
Title: Android with user-defined notification sound

When app in background always the default notification sound was playing.

I added following lines in GCMIntentService.java:

NotificationCompat.Builder mBuilder =
new NotificationCompat.Builder(context)
.setDefaults(Notification.DEFAULT_ALL)
.setSmallIcon(context.getApplicationInfo().icon)
.setWhen(System.currentTimeMillis())
.setContentTitle(extras.getString("title"))
.setTicker(extras.getString("title"))
.setContentIntent(contentIntent);

after this lines i added:

String soundName = extras.getString("soundname");
if (soundName != null) {
Uri soundUri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + getPackageName() + "/raw/" + soundName.replace("-", "").replace(".mp3", ""));
mBuilder.setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_VIBRATE);
mBuilder.setSound(soundUri);
}

And i stored my mp3 files in res/raw folder. (without '-' in filename).