Posts

Showing posts from May, 2019

Multiple language application

Multiple language application This below code is use to change application language. Set strings in string.xml file <string name="english">en</string> <string name="arabic">ar</string> Add method in Utils.java class /** * Change language * @param context * @param locale for ex. "en", "ar" */ public static void forcefullyLocaleChange(Context context, String locale) {     Locale.setDefault(new Locale(locale));     Resources res = context.getResources();     DisplayMetrics dm = res.getDisplayMetrics();     Configuration conf = res.getConfiguration();     if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {         conf.setLocale(new Locale(locale));     } else {         conf.locale = new Locale(locale);     }     res.updateConfiguration(conf, dm);     Log.d("LANGUAGE", getCurrentLanguage()); } Add this code in your activity file /** * By selecting language call this method and pas