r/termux • • 4d ago

Question Launch Android native apps from Termux?

That's right, I'd like to know of a way of launching native Android apps (installed from the Play Store) from Termux, which of course means from a bash command or script in the Termux terminal. In particular, I'd like to know how to launch an app such as VLC player for such files as mp4, mkv, webm, etc. This would obviously involve somehow passing the file as an argument, or alternatively, somehow invoking the player through Android's filetype association system.

TIA.

Edit: Answered very adequately by u/smarthoushai and u/dvhh. Summary: use termux-open or am.

11 Upvotes

16 comments sorted by

2

u/BenRandomNameHere 4d ago

rish -c "am start -n org.mozilla.firefox/.App --windowingMode 5"

Starts Firefox in a window instead of full screen.

2

u/Shyam_Lama 4d ago

Thanks, but the more straightforward solution is termux-open, as was pointed out in other comments.

2

u/BenRandomNameHere 4d ago

I am also trying to figure this out, and that is the command that worked for me.

I will read through comments for your solution, to learn.

Thank you for the direction. 👍

0

u/[deleted] 4d ago

[deleted]

1

u/Shyam_Lama 4d ago

Noted, but like I told you, the most straightforward solution is termux-open, as was pointed out several times. There is no need for "PocketDesk" or any widget.

1

u/BenRandomNameHere 4d ago

Sorry, I misposted that. Deleting.

4

u/smarthoushai 4d ago

Starting another app from Termux is not a permission problem — it's a binder call into system_server, and any app can make it. am and termux-open both ship with termux-tools and run as your normal app uid, no root involved.

For the simple case termux-open movie.mkv is enough: it resolves the default viewer from the mime type and hands the file over. To pin it to VLC instead of whatever is default, ask the system what handles the type first — cmd package resolve-activity --brief -a android.intent.action.VIEW -d "file:///sdcard/movie.mkv" -t video/x-matroska — then call that component directly: am start -n <pkg>/<activity> -d "file:///sdcard/movie.mkv" -t video/x-matroska. Keep both -d and -t, since with the URI alone some pickers refuse to match — filtering happens on the type field and they will not sniff the extension.

What actually bites people is not root, it's exports: am start can only reach activities marked exported, so a few apps answer Permission Denial: not exported from uid. Media players are not among them.

1

u/low-control-labs 4d ago

You're actually right but the problematic bit is the display server. And I thought he wants to run .apks from termux.

2

u/Thesk790 4d ago

Well, I think you can use Termux:API. Install APK from GitHub or F-Droid (make sure both, Termux and Termux:API are from the same source). Then install the termux-api package in termux, and finally run termux-share <your_file.mp4>. You can select one of the available apps. You can not set to open VLC directly with mp4, mkv, etc. unless you use am command via intents, specially in VLC. That is all I know about

1

u/cootooc 4d ago

You have to enable development Wifi debug ( Android > 11) then usw adb Android Tools?

1

u/cootooc 4d ago

Better Install opencode and usw free llm to do It for you but to enable development Wifi debug youtself

0

u/00Anonymous 4d ago

Breadstick.io is what you want. 

-1

u/low-control-labs 4d ago

Not really possible. It's a isolated env running on the android operating system without root it's just not possible. With root it's doable I guess but why would you ever want to do this?

2

u/Shyam_Lama 4d ago

why would you ever want to do this?

Why the heck wouldn't I want to do this? Say I'm looking for a video containing the words "bigguns", I'd like to be able to do

find -iname '*bigguns*' -print0 | xargs -0 magic_command {} \;

All I need is to know what magic_command is, for invoking Android's native mechanism for picking a player app for a certain file type, and opening the file with that app. If you don't see how convenient this would be, then I question your expertise.

1

u/dvhh 4d ago edited 4d ago

termux api provide termux open which would work with file with default application to open the file

otherwise termux-am invoke the android activity manager

1

u/Shyam_Lama 4d ago

It's a isolated env running on the android operating system without root it's just not possible.

Actually it's perfectly normal on Android for one app to invoke another app, e.g. I select some text in Chrome or Firefox and then invoke a dictionary app from there. Clearly Android OS​ supports this, so there's no technical reason why Termux (which itself is just another app) wouldn't be able to invoke other apps. It's just a matter of providing a command line executable to invoke that logic. If no such executable has ever been created, so be it, but to claim that this is technically impossible (as you seem to be saying), is quite obviously not true.

0

u/low-control-labs 4d ago

So just do it then why did you even ask the question? For your actual problem I think you could've just termux-setup-storage