Android Notification sound defaulting back instead of playing custom sound

我与影子孤独终老i 提交于 2019-12-12 14:55:09

问题


Has anybody experienced this? I use notification.sound to set a custom sound and a phone still uses the default sound.

I copied a sound from audio-resources.zip/audio/alarms/Instance.mp3. (You can download audio-resources.zip here). I copied it and moved/renamed it to res/raw/notification.mp3.

I am using this code to make the sound.

//Old way: notification.defaults |= Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE;
notification.defaults |= Notification.DEFAULT_VIBRATE;
notification.sound = Uri.parse("android.resource://my.package.name/raw/notification");

That commented out line is what I was using. It made a sound, presumably the default notification sound. The other two lines are what I am using now.

The old way did not make a sound on the emulator, but it made a sound on the customer's phone (expected). The new way made the correct sound on the emulator, but the customer still hears the old sound.

  • The customer has indeed installed the update. Confirmed by the server receiving a new versionCode (originally from AndroidManifest.xml) and the app telling the user he is up to date. (this is not a market app)
  • The sound comes from a BroadcastReceiver which is triggered by the Alarm Manager
  • I have tested on the emulator using the same download link from the same server and I can't recreate.
  • The customer's sound "is nothing that resembles a beep". If you listen to Instance.mp3, you will know, it is clearly 5 beeps with about a quarter second between beeps.

Now the crazy thing about this is that I would expect the sound to be missing entirely, not to fail back to the default???

I will have the customer reboot his phone and do another clean test (which he has probably already done), but I don't have any more ideas. Do you have any?


回答1:


Item resolved after rebooting the phone. Don't know why. It was not needed on the emulator. I guess the alarms sitting out there during the upgrade was not helpful.



来源:https://stackoverflow.com/questions/5682321/android-notification-sound-defaulting-back-instead-of-playing-custom-sound

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!