再次介绍一下 O+上的通知声音。有些手机的“通知设置”窗口没有显示声音选择按钮(甚至没有振动按钮)。以下是几个例子:
(不是小品牌.我想说)
在Android8上使用Gmail应用程序(菜单、->设置、->帐户、->通知设置)对它们进行了测试。
在这里,Android O - Notification Channels - Change Vibration Pattern or Sound Type是一个避免“标准”窗口的解决方案,但是我们为什么要重新发明轮子呢?
我还有别的选择吗?
谢谢,
最大值
这是一张来自荣誉9/ Android 8.0.0的截图。频道名为"Mail“(意大利语为”Posta“)。对于声音(意大利语中的“Suoneria”),只有一个开关。

发布于 2018-11-07 08:05:43
真是一团糟。您需要为不同的品牌/设备添加解决方案。这就是我们用来处理它的流程:
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && !isDeviceWithWorkaround()) {
// Send to notification channel settings (See https://developer.android.com/training/notify-user/channels#UpdateChannel)
}else{
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, "Sound");
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, Uri.parse(someExistingRingTone));
if (isDeviceWithWorkaround()) {
intent.setPackage("com.android.providers.media");
}
try {
startActivityForResult(intent, reqCode);
} catch (ActivityNotFoundException e) {
if (isDeviceWithWorkaround()) {
Log.i(TAG, "Failed to find preferred package [" + intent.getPackage() + "]. Trying again without package.");
intent.setPackage(null);
startActivity(intent);
}
}
}所以现在发生的事情是,如果它是一个已知问题的设备,就像你谈论的那样,我们会把它们发送给好的旧铃声选择器。
我相信com.android.providers.media包并没有任何活动可以启动安卓,但在华为,它打开了媒体商店,在那里我们可以得到一个铃声URI,可以用作通知声音。(我们不希望用户最终使用其他可能无法工作的铃声选择器。我们一直建议我们的用户使用extended,但它不会在安卓8上与华为合作)。
https://stackoverflow.com/questions/51983074
复制相似问题