droidcam
droidcam copied to clipboard
Auto-Launch android app over adb
This is a feature that looks interesting for getting droidcam even more similar to an actual webcam.
Either autostart on phone boot, or launch via adb shell when connected to pc.
What would be the adb command to launch the app?
You would need to know the activity you're launching inside the app, but the command is adb shell something https://developer.android.com/studio/command-line/adb#am
Right, if we can determine the activity name then at least we can run adb blah blah && droidcam-cli ... even if it's not built-in
try (replace 'droidcam' with with 'droidcamx' for the paid app)
adb shell am start -n com.dev47apps.droidcam/com.dev47apps.droidcam.DroidCam -a android.intent.action.MAIN -c
android.intent.category.LAUNCHER
Update: I just saw this is the Linux only repo, I ran into this error on my Windows, I think it applies to Linux as well. Just remove the Windows cmd part and it should work as well.
In case somebody else runs into this issue with an "Android Service Error" and the problem that the app does not start: Get your phone open the screen unlocked, then it works. I removed my screen lock (since it's a webcam only smartphone), and then created a Windows shortcut as follows:
"C:\Windows\System32\cmd.exe" /k adb shell am start -n com.dev47apps.droidcam/com.dev47apps.droidcam.DroidCam & adb shell input keyevent 26 & exit
"adb shell input keyevent 26" is the code for the pressing the power button and thus activates the screen.
Hope this helps someone else too :)
adb shell am start -n com.dev47apps.droidcamx/com.dev47apps.droidcamx.DroidCamX
For people googling, winding up here, and wondering about the way to start droidcamx :')
thank you @aramg & @magnusjjj! I've written a neat little shell script inspired by your adb commands, which also checks, if DroidcamX is in the foreground:
#!/usr/bin/env bash
display=$(adb shell dumpsys nfc | grep 'mScreenState=' | cut --delimiter="=" -f 2)
pid=$(adb shell pidof com.dev47apps.droidcamx)
foreground=$(adb shell dumpsys activity recents | grep 'Recent #0' | cut -d= -f3 | sed 's| .*||' | cut -d: -f2)
if [ ! -z "$pid" ]; then
echo DroidcamX already running
if [ $foreground != "com.dev47apps.droidcamx" ]; then
echo "bringing DroidcamX to foreground" && adb shell am start --activity-single-top com.dev47apps.droidcamx/com.dev47apps.droidcamx.DroidCamX
else
echo "DroidcamX already in foreground"
fi
else echo "starting DroidcamX..." && adb shell am start -n com.dev47apps.droidcamx/com.dev47apps.droidcamx.DroidCamX
fi
if [ "$display" = "OFF_UNLOCKED" ]; then
echo "display off, turning on"
adb shell input keyevent 26
elif [ "$display" = "ON_UNLOCKED" ]
then echo "display on and unlocked"
elif [ "$display" = "OFF_LOCKED" ]; then
adb shell input keyevent 26
echo please unlock screen
elif [ "$display" = "ON_LOCKED" ]; then
echo please unlock screen
fi
manually starting DroidcamX on my phone was super annoying, which i don't have to do anymore :)
adb shell am start -n com.dev47apps.obsdroidcam/com.dev47apps.obsdroidcam.MainActivity -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
command for DroidCam OBS