NotificationCompat.Builder setSound()不适用于.mp3资源和产品风格

时间:2017-08-23 12:51:22

标签: android android-notifications android-resources android-productflavors

这就是我正在做的事情,它仍会在模拟器和设备上播放默认声音:

Uri sound = Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.sleep_tone);
...
mNotificationBuilder.setSound(sound);

在我添加产品口味之前,它确实有效。我有2种产品口味,包装名称后缀为.free和.pro。用context.getPackageName()com.mycompany.myapp.free替换.pro并不起作用,根本没有后缀也不起作用。 mp3文件存储在main / res / raw下。如果我将它存储在pro / res / raw中并不重要,它仍然无法正常工作。我该如何访问它?

0 个答案:

没有答案