问题
我们正在更改应用程序内的区域设置,除了指纹对话框中的提示外,一切正常。无论我们设置什么语言,我们总是有英文提示:
- 触摸指纹传感器
- 未识别
- ETC...
环境
- 使用的组件:androidx.biometric.BiometricPrompt
- 使用的版本:1.0.0.0-alpha04
- 设备/Android 版本转载于:emulator API 28
如何设置语言环境:
private fun setNewLocaleAndRestart(language: String) {
LocaleManager(this).setNewLocale(language)
//restarting app
val i = Intent(this, SplashScreenActivity::class.java)
startActivity(i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK or Intent.FLAG_ACTIVITY_NEW_TASK))
finish()
System.exit(0)
}
class LocaleManager(val context: Context) {
val sharedPreferenceManager = createSharedPreferenceManager(context)
fun setLocale(): Context = updateResources()
fun setNewLocale(language: String): Context {
return updateResources(language)
}
private fun updateResources(l: String? = null): Context {
val language = l ?: sharedPreferenceManager.language
if (language.isBlank()) return context
val locale = Locale(language)
Locale.setDefault(locale)
val res = context.resources
val config = Configuration(res.configuration)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
config.setLocale(locale)
return context.createConfigurationContext(config)
} else @Suppress("DEPRECATION") {
config.locale = locale
res.updateConfiguration(config, res.displayMetrics)
return context
}
}
}