Search code examples
android-activityadbmonkeyrunnercalabash-android

How to translate an ADB command line control ---> to MonkeyRunner Python script


When I run this on the command line it brings up the screen on my device to change the language.

$ adb shell am start -a android.settings.LOCALE_SETTINGS

works great.

I am trying the same functionality into a Python script that monkeyrunner calls. How do you translate the above into something that will work with monkeyrunner / python?

e.g. I tried:

device = Monkeyrunner.waitForConnection()
package = 'android.settings'
activity = 'LOCALE_SETTINGS'
runComponent = package + '/' activity

device.startActivity(component=runComponent

This does nothing. No error message. But nothing.

Any suggestions?


Solution

  • android.settings.LOCALE_SETTINGS is not a component but an action. You can do either

    device.startActivity(action='android.settings.LOCALE_SETTINGS')
    

    or

    device.startActivity(component='com.android.settings/com.android.settings.Settings$LocalePickerActivity')