I have a feature in my app where user can select various language at runtime from inside the app and it was working fine till I was deploying app on play store in APK format but it stopped working since i started deplyoing my app in App Bundle format. Default string resources are not being replaced with the one that user has selected but when I change whole device language from device's settings option, then my app gets updated with new configured resources from play store and everything works fine. Is there any way I can enforce all the strings resouces to pushed along with base apk or any other way I am unaware of? Please help. The code I am using to change language is -
Locale locale = new Locale(langCode); //langCode is the code of the language user has selected
Locale.setDefault(locale);
Resources res = parentContext.getResources();
Configuration config = res.getConfiguration();
config.setLocale(locale); // = locale;
res.updateConfiguration(config, parentContext.getResources().getDisplayMetrics());
答案 0 :(得分:3)
编辑:
PlayCore API现在支持按需下载另一种语言的字符串:https://developer.android.com/guide/app-bundle/playcore#lang_resources
我找到了解决方法here。从那里复制
目前,您可以通过在build.gradle中添加以下配置来禁用按语言拆分
android {
bundle {
language {
// Specifies that the app bundle should not support
// configuration APKs for language resources. These
// resources are instead packaged with each base and
// dynamic feature APK.
enableSplit = false
}
}
}