android-emulatorandroid-virtual-devicemonkeyrunnerandroidviewclientmonkey

AndroidViewClient - How to get notified when the Android Virtual Device start process is completed?


I use AndroidViewClient in order to use MonkeyRunner through Python. I need to start the AVD programmatically and get notified when the AVD start process is completed. How can I catch that event? The execution just does not reach the line after the subprocess.run() function.

Here is how I start my AVD:

subprocess.run('emulator -avd Nexus_5_API_26 -wipe-data', shell=True)
// the execution just does not reach this line

Solution

  • You can detect that the AVD is ready using

    adb wait-for-device
    

    also, to start the emulator in the background you need Popen.