再次关于Android O+ 上的通知声音。
有些手机的“通知设置”窗口不显示声音选择按钮(甚至不显示振动按钮)。
这里有几个例子:
(不是小品牌......我会说)
他们在 Android 8 上使用 Gmail 应用程序(菜单 -> 设置 -> 帐户 -> 通知设置)进行了测试。
Here Android O - 通知通道 - 更改振动模式或声音类型 https://stackoverflow.com/questions/45081815/android-o-notification-channels-change-vibration-pattern-or-sound-type/是避免“标准”窗口的解决方案,但我们为什么要重新发明轮子呢?
我还缺少其他选择吗?
谢谢你,
Max
P.S.
Here is a screenshot from a Honor 9 / Android 8.0.0.
Channel name is "Mail" ("Posta" in Italian). For sound ("Suoneria" in Italian) there is only an On/Off switch.
一团糟。您需要为不同品牌/设备添加解决方法。这是我们用来处理它的流程:
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
在原生 Android 上没有启动活动,但在华为上它会打开媒体商店,我们可以在其中返回可用作通知声音的铃声 URI。 (我们不希望用户最终使用其他可能不起作用的铃声选择器。我们一直建议用户使用https://play.google.com/store/apps/details?id=com.angryredplanet.android.rings_extended https://play.google.com/store/apps/details?id=com.angryredplanet.android.rings_extended但它不适用于 Android 8 上的华为)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)