Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Huawei EMUI 8 Oreo - Notification Channel - Tone

Some users are reporting on Huawei EMUI 8.0 Oreo that the Notification Channel does not have the option to change tone "Sound" / "Notification Tone" from the app!

As of the official docs the developer can't change the settings anymore.
So how can I add an option for Huawei phones to change the "Notification Tone" again?

And does anyone know why the hell Huawei removed this feature?
I don't find official docs from Huawei how we can now let the user change the notification tone.

Offical docs I am referring:
https://developer.android.com/reference/android/app/NotificationChannel.html

https://developer.android.com/reference/android/app/NotificationChannel.html#setSound(android.net.Uri, android.media.AudioAttributes)

like image 535
chrisonline Avatar asked Dec 26 '17 19:12

chrisonline


2 Answers

We ran into the same issue recently. It is not a nice solution, but WhatsApp is doing the same. Basically we show a ringtone selection inside our app and then delete and recreate the notification channel with a new channel id and the selected ringtone uri. You can copy most settings made to the channel to the new one except 'do not disturb'.

Like I said it is not a nice solution and I don't know what will happen if the channel is recreated a lot. But hopefully the ringtone is not changed too often.

Note: The notification settings screen displays the number of deleted channels, as a spam prevention mechanism.

like image 173
Devenias Avatar answered Nov 11 '22 05:11

Devenias


Faced with same issue on chinese devices. Firstly, i have same solution like describe @Devenias. How it works in system: when you're defining a new channel, NotificationService save this channel in xml, after you changed it, it still contains in this xml. So on a new change of channel, NotificationService will check if it have a channel with a same name, and just retrieve it. So i make new channel with a new settings all the time, when user change vibration or ringtone in app. Also it works like a cache, just make unique channel name for pair<ringtone, vibration>. This solution is pretty hacky, since it works good on Honor's, Huawei's, Samsung's devices and Xiaomi Mi A1, but it have been crashing NotificationService with NullPointer in SystemUI on Xiaomi Mi Mix 2 (device make soft reboot, if SystemUI service crashed), so don't use this solution.

So nowadays a safe workaroud is to play sound and vibration manually.

like image 32
HeyAlex Avatar answered Nov 11 '22 06:11

HeyAlex