Making sure Android Virtual Device is up - a better way

For a while we've been using a rather inprecise mathd of checking if a started android virtual device is up and ready to be used. Even after adding delays (hrmpfh!) the code ended up to be dependent on things like the speed of the host - not good!

With some links from Julian Harty we found a way better solution. Removing some debug (to log file) statements we implemented the check if the AVD s up by this:

    STOPPED=$($ADB -s emulator-$ANDROID_PORT shell "getprop init.svc.bootanim"  2>/dev/null | grep topped | wc -l)
    if [ $STOPPED -eq 0 ]
        return 1
    return 0
The important thing here is of course $ADB -s emulator-$ANDROID_PORT shell "getprop init.svc.bootanim". With this little trick we can now check if and AVD is up and running. This makes scripting towards AVDs easier and quicker (no more long delays just to make sure).





No comments yet. Be the first.