How can I modify the default locale in android?
By default, the andro开发者_开发问答id system's default location is US and language is en. But I want to set the default location to another country. So, the users will see their mother language when the first time startup android.
I have tried to modify the code(/dalvik/libcore/luni/src/main/java/java/util/Locale.java
), changed the locale's default value. But no effect.
Can you tell me how to set the default location?
*I want to make an android image, then burn it to the device, when the android starts up the first time, I want its os language is not English but another language.
thanks for all you reply.
i have found the method to change the default language.
just modify the file(build/core/Makefile)
.
set PRODUCT_DEFAULT_LANGUAGE
and PRODUCT_DEFAULT_REGION
to what you want to set.
I make customer build via build/target/product/core.mk
Samples:
PRODUCT_PROPERTY_OVERRIDES := \ ro.config.notification_sound=OnTheHunt.ogg \ ro.config.alarm_alert=Alarm_Classic.ogg \ ro.config.ringtone=BirdLoop.ogg \ persist.sys.language=zh \ persist.sys.country=CN \ persist.sys.timezone=Asia/Shanghai
This is what i do to make a simplified-chinese customer build.
Have you already checked out this part?
private Locale() {
languageCode = "en"; //$NON-NLS-1$
countryCode = "US"; //$NON-NLS-1$
variantCode = ""; //$NON-NLS-1$
}
It starts at line 212 in Locale.java. Is this the part where you've set your default values? If so then please post that bit up so I can check it out.
EDIT: Actually if you can post your whole Locale.java up on Pastebin. http://pastebin.com/
The easiest way might be to insert a local SIM before boot. But in my case the timezone wouldn't be set automagically not even then.
For lineage 18, first boot setup, custom build:
Add base locale as top on PRODUCT_LOCALES
in build/target/product/full_base.mk
like
PRODUCT_LOCALES := de_DE
To set the default timezone via makefiles didn't work for me, but it worked to hardcode it in the SetupWizard.
So change line 84 in packages/apps/SetupWizard/src/org/lineageos/setupwizard/DateTimeActivity.java
from
mCurrentTimeZone = TimeZone.getDefault();
to:
mCurrentTimeZone = TimeZone.getTimeZone("Europe/Amsterdam");
Check first which timezones are at hand by browsing the list!
Use java.util.locale
and use method getISOcounty
, getISOLanguage
etc...
to know more in detail go through http://developer.android.com/reference/java/util/Locale.html
精彩评论