Is it possible to run termux commands through Activity Starter?

Hmmm, so adding this to the Extras (which I already have...) is not enough?

image

No, Activity Starter can't start a service.
That extra value defines whether service should be sticky(auto start itself when killed) or not.

Made some progress, using

Activity Package = com.termux
Activity Class = com.termux.app.TermuxActivity

I can at least open termux from AppInventor and return with the back button.

Done some logcats on termux and the test app. can't find anything of much use.

If anyone wants a scour through some code: (note, i attempted many things so some errors were caused rather than embedded)

controltermux.txt (944.8 KB) termux.txt (16.0 KB)

You can always start an Activity using Activity Starter Component.

I forgot to put up the aix file for completeness

test.termux.permission.aix (4.2 KB)

Current blocks, in case there is anything wrong there:

Is it working? :thinking:

Unfortunately not. Error 601 no corresponding activity....

Other than installing the extension, should I be doing anything with it? There are no blocks to do anything...

An extension is needed which can start service by taking intent parts as parameter(s).
I think that also needs to be added in the component.

Here are a few (relevant) lines of the Manifest from a decompiled Termux app:

<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>

<service android:exported="false" android:name="com.termux.app.TermuxService"/>
<service android:exported="true" android:name="com.termux.app.RunCommandService" android:permission="com.termux.permission.RUN_COMMAND">
<intent-filter>
<action android:name="com.termux.RUN_COMMAND"/>
</intent-filter>
</service>

As you can see, there are some services declared.
I guess these are missing in yours.

1 Like

Because "Android" (or Termux or AppInventor's Activity Starter, or a combination of all three) is making it so difficult (for me, at least), I decided to search out an alternative approach.

This I found in Termux, with the ability to setup an apache http server with php. With a simple php file in Termux's htdocs directory, I am able to send linux commands using shell_exec, and receive back the standard output just using the web component. This works in a similar fashion to Juan's terminal extension. Termux provides the user with a much broader range of commands and programs to use than that which is available on most devices, plus it also has r/w access to the device storage directories, sdcard and files.

I will write a more detailed guide once I have had time to flesh out my demo app.

In the meantime, if someone is able to get things working using activityStarter (and/or an extension), then I am all ears :slight_smile:

1 Like

Those services have been used in Termux app and caller app need not to declare any of those.

Maybe this will work:
com.sunny.IntentStarter.aix (12.7 KB)

Tried this:

Error 601 no corresponding activity

You should either use StartService or StartForegroundService method.

Same error, unfortunately.

Is it really possible to use an IntentService / ForegroundService without declaring any service in the Manifest?

Yes, as long as those services belong to other apps.
In fact you don't have to use those services and only have to start them with appropriate extras.

I am getting following error:

I/IntentStarter(27431): Adding extra, key = com.termux.RUN_COMMAND_PATH value = /data/data/com.termux/files/usr/bin/ls

I/IntentStarter(27431): Adding extra string, key = com.termux.RUN_COMMAND_PATH value = /data/data/com.termux/files/usr/bin/ls

I/IntentStarter(27431): Adding value as String

I/IntentStarter(27431): Adding extra, key = com.termux.RUN_COMMAND_WORKDIR value = /data/data/com.termux/files/home

I/IntentStarter(27431): Adding extra string, key = com.termux.RUN_COMMAND_WORKDIR value = /data/data/com.termux/files/home

I/IntentStarter(27431): Adding value as String

W/ActivityManager(  512): Unable to start service Intent { act=com.termux.RUN_COMMAND cmp=com.termux/.app.RunCommandService (has extras) } U=0: not found

Found a similar issue:

1 Like

Hello Everyone ! In this profile I'm sharing some of my works and experience About cybersecurity and Linux commands. [https://www.termuxcommands.com/]