Reboot and launch an Android app via ADB
I'm using an old Android phone as a webcam. The camera lens is great, the DroidCam software is nifty, but the Android OS behind it is old and dying. My phone often needs rebooting. Which means that the app also needs restarting. The phone's screen faces away from me, so I can't interact with it.
This is a quick guide (mostly notes to myself) about rebooting and starting an app from the command line.
To find the package name, run
BASHadb shell pm list packages -f | grep -i PackageName
In my case, the package is called com.dev47apps.droidcamx
To launch an app from your computer's shell, run
BASHadb shell monkey -p com.dev47apps.droidcamx 1
You can read more about the Android Test Monkey.
Putting it all together in a shell script is as simple as:
BASHadb reboot
sleep 60
adb shell monkey -p com.dev47apps.droidcamx 1