android - Letting user choose language at application level -


this question has answer here:

i have localized android app , localized text displayed when user switches local on device.

but if user wants app show text in english , still don't change locale. there thing can in app asking if wants set locale @ app level. if chooses so, how make app presume locale in english , not german (i mean there api setdefaultlocale())?

refer :- refer here or

<activity     android:name=".ui.someactivity"     android:configchanges="locale"     :     : </activity> 

and invoke method oncreate in activity:

public static void setlanguage(context context, string languagetoload) {     log.d(tag, "setting language");     locale locale = new locale(languagetoload); //e.g "sv"     locale systemlocale = systemlocale.getinstance().getcurrentlocale(context);     if (systemlocale != null && systemlocale.equals(locale)) {        log.d(tag, "already correct language set");        return;     }     locale.setdefault(locale);     android.content.res.configuration config = new android.content.res.configuration();     config.locale = locale;     context.getresources().updateconfiguration(config, context.getresources().getdisplaymetrics());     log.d(tag, "language set"); } 

Comments