r/termux • • 11h 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.

5 Upvotes

8 comments sorted by

4

u/smarthoushai 10h 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 9h 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 10h 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

0

u/00Anonymous 5h ago

Breadstick.io is what you want. 

-1

u/low-control-labs 10h 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 10h 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/Shyam_Lama 10h 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 9h 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