droidcam icon indicating copy to clipboard operation
droidcam copied to clipboard

Auto-Launch android app over adb

Open AvverbioPronome opened this issue 4 years ago • 8 comments
trafficstars

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.

AvverbioPronome avatar Jan 14 '21 09:01 AvverbioPronome

What would be the adb command to launch the app?

PythonNut avatar Feb 02 '21 21:02 PythonNut

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

AvverbioPronome avatar Feb 02 '21 23:02 AvverbioPronome

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

PythonNut avatar Feb 02 '21 23:02 PythonNut

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

aramg avatar Feb 03 '21 05:02 aramg

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 :)

matt3o avatar Feb 10 '22 18:02 matt3o

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 :')

magnusjjj avatar Jul 06 '22 07:07 magnusjjj

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 :)

xeaon avatar Jul 27 '23 06:07 xeaon

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

kustraslawomir avatar Feb 08 '24 07:02 kustraslawomir