某些手机似乎缺少更改通知的声音类型的选项

某些手机似乎缺少更改通知的声音类型的选项

本文介绍了Android O +:某些手机似乎缺少更改通知的声音类型的选项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

再次了解Android O +上的通知声音.在某些手机的通知设置"窗口中,没有显示声音选择按钮(甚至没有振动按钮).这是几个示例:

Again about notification sound on Android O+.There are some phones where the "notification settings" window doesn't show the sound selection button (and not even the vibration button).Here are a couple examples:

  • 三星A5
  • 华为荣誉观10

(不是小品牌...我会说)

(not minor brands... I would say)

它们已在Android 8上通过Gmail应用(菜单->设置->帐户->通知设置)进行了测试.

They were tested with Gmail app (menu -> Settings -> account -> Notification settings) on Android 8.

此处 Android O-通知渠道-更改振动模式或声音类型是避免标准"窗口的解决方案,但是为什么我们要重新发明轮子呢?

Here Android O - Notification Channels - Change Vibration Pattern or Sound Type is a solution to avoid the "standard" window, but why should we reinvent the wheel?

我还有其他选择吗?

谢谢

最大

P.S.这是Honor 9/Android 8.0.0的屏幕截图.频道名称为邮件"(意大利语为"Posta").对于声音(意大利语中的"Suoneria"),只有一个On/Off开关.

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.

推荐答案

一团糟.您需要为不同的品牌/设备添加解决方法.这是我们用来处理它的流程:

It's a mess. You need to add workarounds for the different brands/devices. This is the flow we're using to deal with it:

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

因此,发生的事情是,如果这是您所谈论的已知问题的设备,我们会将其发送到旧的铃声选择器.

So what's happening is that if it's a device with a known issue as you talk about we send them to the good old ringtone picker.

我相信程序包com.android.providers.media没有开始在现货Android上启动的活动,但是在Huawei上,它随后打开了Media Store,在其中我们获得了可用作通知声音的铃声URI. (我们不希望用户最终遇到其他可能无法使用的铃声选择器.我们一直建议用户使用 https://play.google.com/store/apps/details?id=com.angryredplanet.android.rings_extended 但它不会在Android 8上与华为合作).

I believe that the package com.android.providers.media doesn't have an activity to start on stock Android, but on Huawei it then opens the Media Store where we get back a ringtone URI that can be used as notification sound. (We don't want the user to end up in some other ringtone picker that might not work. We have always recommended our users to use https://play.google.com/store/apps/details?id=com.angryredplanet.android.rings_extended but it won't work with Huawei on Android 8).

这篇关于Android O +:某些手机似乎缺少更改通知的声音类型的选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-07 05:57