wsvn53 / scrcpy-mobile

Ported scrcpy for mobile platforms, to remotely control Android devices on your iPhone or Android phone.
MIT License
594 stars 35 forks source link

Feature Request: Add launch-app parameter to URL scheme #54

Open plia7 opened 9 months ago

plia7 commented 9 months ago

Hello,

Is it possible for you to add a new parameter to the URL scheme called launch-app, so if I pass a value to it, it will launch this app when I connect?

For example: scrcpy2://host:42011?stay-awake=true&launch-app=com.kendamasoft.notificationmanager/.view.GroupListActivity

This will result in launching the Notification Manager app when I connect.

Since you have access to the adb of the host, you could just execute the following command:

adb shell am start -n $launchApp

or in this example:

adb shell am start -n com.kendamasoft.notificationmanager/.view.GroupListActivity

Thank you.

plia7 commented 8 months ago

@wsvn53 有这方面的更新吗? 这可行吗?谢谢.

plia7 commented 8 months ago

Hello @wsvn53,

Let me explain why this feature is needed:

Basically I have a shortcut on my iPhone that would open scrcpy-ios using the ios url scheme, but the shortcut also supposed to look like an app icon, so when it opens, I want to basically see the same when it connects to the app.

Right now, I use the android adb, to send a command

adb shell am start -n $launchApp

Before connecting with scrcpy-ios so when I’m connected the app opens.

The problem is it’s slowing down the process for me to first issue this command.

Since scrcpy-ios already uses adb to talk with the android phone, I think it should be easy enough for you to execute that command if I provide you with the full app main package activity name so by the time scrcpy-ios connects the app already opens?

For example, on my android I have the ChatGPT app which I don’t have on my iphone (because I’m using a lower ios version which is incompatible).

So I created a shortcut that looks like ChatGPT icon and name and now when I click it, it uses scrcpy-ios to connect, but before it tells the android it needs to open ChatGPT app. The problem is it’s slightly slowing down the process of quickly connecting to the android phone with that app being opened.

Please let me know what do you think.

Thank you.

plia7 commented 8 months ago

@wsvn53 Here is a video illustration what it should look like (and hopefully it will be even faster with this new option added):

For the shortcut I'm using here is:

scrcpy2://host:42011?stay-awake=true&launch-app=com.openai.chatgpt/.MainActivity

https://github.com/wsvn53/scrcpy-mobile/assets/134864072/0511281a-1dbe-45e3-a20a-d60493432614

Thanks.

plia7 commented 7 months ago

@wsvn53 Actually instead of a specific adb command (like launch) can you let the user add any custom command for example:

adb shell am start -a android.intent.action.VIEW -d http://www.stackoverflow.com

I guess you can do that through a new ios url scheme? That way it can be used for any case needed and it will be more general.

Thanks.

fbloise commented 2 months ago

This would be awesome, something like a manual mode. My goal is, using a dummy hdmi, trigger Samsung Dex and be able to view it in iPad using this app, by triggering the adb scrcpy parameter --display 2 to force Dex display instead of the main android phone display.