Code to Change Android Phone language programmatically,Android

Change Android Phone language programmatically


public static void change_setting_arabic(Context con) {
  try {
                        /** here add language code */
   Locale locale = new Locale("ar");

   Class amnClass = Class.forName("");
   Object amn = null;
   Configuration config = null;

   // amn = ActivityManagerNative.getDefault();
   Method methodGetDefault = amnClass.getMethod("getDefault");
   amn = methodGetDefault.invoke(amnClass);

   // config = amn.getConfiguration();
   Method methodGetConfiguration = amnClass
   config = (Configuration) methodGetConfiguration.invoke(amn);

   // config.userSetLocale = true;
   Class configClass = config.getClass();
   Field f = configClass.getField("userSetLocale");
   f.setBoolean(config, true);

   // set the locale to the new value
   config.locale = locale;

   // amn.updateConfiguration(config);
   Method methodUpdateConfiguration = amnClass.getMethod(
     "updateConfiguration", Configuration.class);
   methodUpdateConfiguration.invoke(amn, config);

  } catch (Exception e) {
   // TODO: handle exception
   Log.d("error lang change-->", "" + e.getMessage().toString());


  1. will you Please send the full source code to my mail :(
    thank you

    1. Hi Krishna
      This complete method is the complete source code for converting the language.
      For that u can just cal this method from Activity and pass the Activity context to that method.
      Use language whatever u want in first line of the method inside try block.


  2. Hi pavan,Nice article .Keep it Up.I used your code,but its not working in emulator.Did you add any Strings value in the Strings.xml file.otherwise could you send the Full source code of the project.My mail id is

  3. This code is for android 2.2+ and before version. Current I need code for android 4.x/5.x/6.x
    Can you provide details for above requirement?

  4. Hi, Thanks for your help.
    This code is for android 2.2+, and before version. Current I need code for android 4.x/5.x/6.x
    Can you provide details for my requirement?


Post a Comment

Popular posts from this blog

Custom Dialog with no title and full screen in Android

code to display .pdf,.text,.DOC,.DOCX,.doc extension files exists in SDCard

Best working code to set Date limits on Date Picker Dialog,in Android