android - How does MoreLocale work? -
i downloaded source code, , seems there connected android settings. want implement it's features in application. how works?
finally found way set android system locale:
public void changelanguage() { iactivitymanager = activitymanagernative.getdefault(); configuration config; try { config = am.getconfiguration(); config.locale = locale.us; // change locale config.usersetlocale = true; am.updateconfiguration(config); backupmanager.datachanged("com.android.providers.settings"); } catch (remoteexception e) { e.printstacktrace(); } }
it requires change_configuration permission:
<uses-permission android:name="android.permission.change_configuration" />
note: in android 4.2 or newer, permission policy has been changed, , 3rd party application can't permission. if have root access, execute pm grant command:
string.format("pm grant $1%s android.permission.change_configuration", new object[]{getpackagename()})
Comments
Post a Comment