【发布时间】:2018-07-17 05:37:14
【问题描述】:
在我的应用程序中,我正在动态更改语言,所以如果我在前台,通知语言会正确出现,但如果我强制关闭应用程序,通知会出现在设备区域设置中。
我已使用以下代码更改上下文区域设置,但强制关闭后它不起作用
fun wrapContext(context: Context?, locale: Locale): Context? {
if (context == null) return null
val configuration = context.resources.configuration
if (getSystemLocale(configuration) === locale) {
return context
}
setSystemLocale(configuration, locale)
val res = context.resources
res.updateConfiguration(configuration, res.displayMetrics)
return context.createConfigurationContext(configuration)
}
任何帮助将不胜感激。
【问题讨论】:
-
@NileshRathod 我正在以编程方式设置语言而不是设备语言
标签: android push-notification notifications android-notification-bar setlocale