Localization/Language preferences doesn't change widget's language in android -


in application let users change language of application.i this:

        public void onupdate(context context, appwidgetmanager appwidgetmanager, int[] appwidgetids) {     // there may multiple widgets active, update of them     final int n = appwidgetids.length;     (int = 0; < n; i++) {         updateappwidget(context, appwidgetmanager, appwidgetids[i]);          int appwidgetid = appwidgetids[i];            //get sharedpreferences         sharedpreferences sharedpreferences = preferencemanager.getdefaultsharedpreferences(context);         //get default local first initialization         string defaultlanguage = context.getresources().getconfiguration().locale.getlanguage();         configuration configuration = new configuration();         //check language preference everytime oncreate of activities, if there no choise set default language         locale newlocalelanguage = new locale(sharedpreferences.getstring("newlanguagepref",defaultlanguage));         //finally setdefault language/locale according newlocalelanguage.         locale.setdefault(newlocalelanguage);         configuration.locale = newlocalelanguage;         context.getresources().updateconfiguration(configuration, context.getresources().getdisplaymetrics());          log.i("defaultlanguage", defaultlanguage);         log.i("prefferedlanguage",sharedpreferences.getstring("newlanguagepref",defaultlanguage));  appwidgetmanager.updateappwidget(appwidgetid, views);           } 

i change preffered local in activities code.but localization doesn't work widgets.widgets appear in local language of phone.

as see, on log lines check default language , preffered language , everthing fine. change according language choise onupdate method of widget.

in opinion, widget can't see custom localization pref because works on homescreen , sees localization pref of phone.is right?

so,is impossible change language of widget?how can handle it?

but localization doesn't work widgets.widgets appear in local language of phone.

you calling updateappwidget(context, appwidgetmanager, appwidgetids[i]); before changing locale. hence, strings via getstring() inside updateappwidget() using default device locale.

move updateappwidget() call after code changes process' locale. if not help, please post code updateappwidget(), perhaps there issue in how setting remoteviews.


Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -