1

I'm using GCM to send push notifications to my android apps. I put some notification sounds in my res folder to use different sounds by setting a key-value pair in my JSON. That works fine with no problem.

Now my question is that:

Is it possible to serve the sounds server-side, so there is no need to put them in res folder and I'm not restricted to the sounds in res folder?

Ali
  • 539
  • 4
  • 18
  • GCM has max message size of 4KB. Hence sending large amounts of data through these systems is not possible. You should use GCM to send a small message to the device indicating that the device should request the large data `payload` directly from the application server. For more details, please refer [here](https://developers.google.com/cloud-messaging/concept-options#payload). So i think you save the sounds on your server, and use the GCM to tell app where can load the data. – bjiang Nov 10 '15 at 17:15
  • @bjiang thanks. I know that I have to save them on my server, I want to know is it possible to play the notification sound with a URL? Can you send me an android code? – Ali Nov 12 '15 at 14:05
  • You can use the `MediaPlayer` to play the sound for the notification. Check the code here:http://stackoverflow.com/questions/5974392/how-to-play-audio-file-from-url-in-android – bjiang Nov 12 '15 at 19:12
  • @bjiang Thanks, but if I use `mediaPlayer`, the sound volume isn't managed by notification volume and is managed by media volume. So if a device is set to vibrate or mute(muting a device will not set media volum to mute too) , it will play the notification sound. And it has a bad experience for users. – Ali Nov 13 '15 at 17:36

0 Answers0