Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android O: Notification Channel localization

I created a Notification Channel like this:

NotificationChannel channel = new NotificationChannel(CHANNEL_ID_FOOBAR, getContext().getString(R.string.notification_channel_foobar), NotificationManager.IMPORTANCE_DEFAULT);
notificationManager.createNotificationChannel(channel);

I provided different translations for R.string.notification_channel_foobar and the channel is created with the language being used at the time of the creation, hence if I eventually change the language of my device, that channel will remain in the old language. Is there a way to overcome this or is this a limitation, i.e. by design?

like image 769
Alécio Carvalho Avatar asked Sep 20 '17 08:09

Alécio Carvalho


People also ask

What is a notification channel in Android?

What Are Notification Channels on Android? “Notification Channels” were introduced in 2017 with Android 8.0 Oreo. The idea is that apps can group different types of notifications into “channels.” Each channel can then be turned on or off by the user. This all happens in the Android settings.

What are advantages of notification channel Android?

What Are the Benefits of Using Notification Channels? By adding notification channels to Android, Google allowed end users to control their receipt of push messages, so that they can be alerted to the types of messages they want most, while opting out of the ones that don't interest them.

How do I get notification channels on Android?

To create a notification channel, follow these steps: Construct a NotificationChannel object with a unique channel ID, a user-visible name, and an importance level. Optionally, specify the description that the user sees in the system settings with setDescription() .

What does data notification channel mean?

Starting with Android 8.0, apps are required to assign their notifications to so-called “notification channels”. These channels determine which signals (notification sound, light, vibration, etc.)


1 Answers

To apply the new language to your notification channel, you need to listen to the ACTION_LOCALE_CHANGED broadcast in your app and call createNotificationChannel again in your receiver.

Recreating the channels will update your strings to the new language (none of the other channel features will be modified). You can see it in the documentation.

like image 70
jmart Avatar answered Sep 27 '22 19:09

jmart