我创建了一个这样的通知 channel :
NotificationChannel channel = new NotificationChannel(CHANNEL_ID_FOOBAR, getContext().getString(R.string.notification_channel_foobar), NotificationManager.IMPORTANCE_DEFAULT);
notificationManager.createNotificationChannel(channel);
我为 R.string.notification_channel_foobar 提供了不同的翻译,并且 channel 是使用创建时使用的语言创建的,因此如果我最终更改了设备的语言,该 channel 将保留旧语言。有没有办法克服这个或者这是一个限制,即通过设计?
最佳答案
要将新语言应用于您的通知 channel ,您需要在您的应用程序中收听 ACTION_LOCALE_CHANGED 广播并在您的接收器中再次调用 createNotificationChannel。
重新创建 channel 会将您的字符串更新为新语言(不会修改任何其他 channel 功能)。您可以在 documentation 中看到它.
关于安卓 O : Notification Channel localization,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46317545/