2

For manual UI testing purposes, on my Android 6.0 & 7.0 devices, I use a shortcut to access language preferences via ADB, then choose one of the three languages ar_DZ, en_GB, fr_FR manually

adb shell am start -n com.android.settings/.Settings\$LocalePickerActivity

Question: is is possible to automate the task of changing the system locale (without root) via ADB?

1
+100

This solution doesn't use directly but meets the end result using automation on unrooted devices

is preferred choice of for me, being simple and free up to 5 macros

Preliminary Steps

  • Install Macrodroid and grant all permissions it asks for

  • Actions desired by OP require root. Macrodroid offers a way to do it by without root using methods, explained here. In essence, it is granting WRITE_SECURE_SETTINGS and CHANGE_CONFIGURATION by running the following commands

adb shell pm grant com.arlosoft.macrodroid android.permission.WRITE_SECURE_SETTINGS

followed by

adb shell pm grant com.arlosoft.macrodroid android.permission.CHANGE_CONFIGURATION

Reboot to ensure commands are updated in the app

Creating Macros and Testing

  • Trigger : Select Empty Trigger

  • Action : Set language → French → France ( corresponding to fr_FR)

  • Constraints : Leave blank

  • Test it by selecting Test Macro from the 3 dots menu of the macro. The system language should change to French . Save the macro for example French. Create two similar macros for other two choices

Creating Home Screen Shortcut

Usually, if you long press the home screen, you will find the icon for widgets collection. Among them you will find Macrodroid widgets. One of them is Macrodroid shortcuts. Drag and drop that to your home screen , it will ask you which macro it should be assigned to , while displaying a list of Macros. Select the macro and rename the widget e.g., French. When you press on that widget corresponding macro is executed. Repeat for other Macros. If you are using a custom launcher you will need to search how to access the widgets collection

Notes

  • Drop down menu selection for languages can be implemented but that would require another Macro. Besides this method of one desktop icon shortcut for each language keeps it simple and easier to debug

  • This method will not work on Oreo (You do not get the set language action, maybe due to the way it is implemented)

  • Yes, I have issue with shortcut option, because it's not available in the widget settings, but bypassed this by using a shortcut maker app, I guess this solution is the fastest to change locale until now, I will accept it unless there is a better solution without third party apps. because the question was asked about using ADB only. – M. Abdelhafid Mar 4 '18 at 7:46
  • I have an issue with RtL allignment in settings with Arabic language, maybe the shell refreshing isn't implemented like the LocalePickerActivity. – M. Abdelhafid Mar 4 '18 at 9:40
  • 1
    The android.stackexchange.com/q/105258/131553 question involving Arabic was fixed by Google in Nougat, and the current device doesn't have an issue with RtL but while using Macrodroid only this time. – M. Abdelhafid Mar 4 '18 at 9:54
  • Let us continue this discussion in chat. – beeshyams Mar 4 '18 at 9:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.