Android的通知声音违约回来,而不是打自定义音效自定义、音效、而不是、声音

2023-09-07 13:48:06 作者:12.帘卷落翠幌

有没有人遇到过这个?我用 notification.sound 来设置自定义声音和手机仍然使用默认的声音。

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

我复制从 audio-resources.zip/audio/alarms/Instance.mp3 声音。 (您可以下载 audio-resources.zip 这里)。我复制它,移动/重命名为 RES /生/ notification.mp3

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.

我用这code键使声音。

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");

这注释掉线是我用。它发出声音,presumably默认的通知声音。另外两行是我现在使用的。

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.

在客户确实已经安装了更新。由服务器接收的新版本code(最初从AndroidManifest.xml中)和应用程序,告诉他是最新的用户认可。 (这不是一个市场的应用程序) 的声音来自一个的BroadcastReceiver 这是由报警管理器触发 在我测试使用来自同一服务器相同的下载链接模拟器,我不能重新创建。 在客户的声音是什么,类似蜂鸣声。如果你听 Instance.mp3 ,你就会知道,这显然是5声有大约四分之一的哔哔声第二之间。 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?

推荐答案

项目重启手机后解决。不知道为什么。它并不需要在模拟器上。我想在升级过程中坐在那里报警是没有帮助的。

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.