Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-Launch android app over adb #129

Open
AvverbioPronome opened this issue Jan 14, 2021 · 8 comments
Open

Auto-Launch android app over adb #129

AvverbioPronome opened this issue Jan 14, 2021 · 8 comments

Comments

@AvverbioPronome
Copy link

AvverbioPronome commented Jan 14, 2021

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.

@PythonNut
Copy link

What would be the adb command to launch the app?

@AvverbioPronome
Copy link
Author

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

@PythonNut
Copy link

PythonNut commented Feb 2, 2021

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

@aramg
Copy link
Collaborator

aramg commented Feb 3, 2021

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 aramg changed the title Feature request: automate app launch when connected via ADB Auto-Launch android app over adb Jul 15, 2021
@matt3o
Copy link

matt3o commented Feb 10, 2022

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

@magnusjjj
Copy link

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

@xeaon
Copy link

xeaon commented Jul 27, 2023

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

@kustraslawomir
Copy link

kustraslawomir commented Feb 8, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants