Android Question Can we make terminal shell apps?

JohnK

Active Member
Licensed User
Longtime User
Hi,

Its been a loooong time since I was here, so sorry if this has been covered recently.

Can we create a terminal app (ie no GUI/Activities, and run directly from the shell / terminal window)?

I wish to do things in the shell / command line, that I cannot do with ASH scripting, but can within B4X
 

DonManfred

Expert
Licensed User
Longtime User
For windows (B4J) you can create nonui Apps. Not on Android.
 
Upvote 0

JohnK

Active Member
Licensed User
Longtime User
thanks. I saw it on the Java Code builder UI, but did not check it in the latest version of B4A.

am I the only one that wants this feature?
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
am I the only one that wants this feature?

What feature are you talking about? If you mean writing a non-UI utility running under Windows or Linux then DonManfred has already answered your question. Look at B4J.
 
Upvote 0

JohnK

Active Member
Licensed User
Longtime User
What feature are you talking about? If you mean writing a non-UI utility running under Windows or Linux then DonManfred has already answered your question. Look at B4J.
No, its android specific. We are in the "B4A - Android" forum. And he answered that it currently does not. And hence the question if I am the only one.
 
Upvote 0

Brian Dean

Well-Known Member
Licensed User
Longtime User
No, its android specific.

Okay. But I think that you should be asking Google this question. They are the "it" that does not currently provide a "terminal app", surely. Or are we talkjing about something like "connectivity services"?
 
Upvote 0

cimperia

Active Member
Licensed User
Longtime User
Thanks for the link @aeric .
 
Upvote 0

JohnK

Active Member
Licensed User
Longtime User
I don't think I am being understood. I am not looking to create a terminal nor use a terminal to run shell scripts. I am looking to create apps that have no UI and can be run directly from a shell command/script, and outputs text to stdout and stderr. They are commands that you run within a terminal. If you are an old windows user, think commands run at the command prompt. For unix, think bash commands/scripts (its almost the same in android).

For example, if you open a terminal on an android device, there are thousands of commands you can run.

Some examples:
Example of a shell command:
getenforce;
Will return the SELinux enforcing state

Example of a shell command:
free;
Will return a summary of your devices memory

Example of shell a command:
cmd package list packages -3;
Will return a list of 3rd party packages installed on the device

Example of shell a command:
dumpsys batterystats;
Will output your devices battery stats and history.

People often confuse these with being a part of ADB, but in most cases they are simply shelling out and running the command on the device from a pc.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I never tested it. I thought we can create a .jar file using B4J and run inside that emulator.
to run a jar file the path to the java executeable must be known. I do not think that there is a JDK installed on my Device.

I do have termux installed.... I tried to call java from the console. No command java found.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Some examples
Yes, right. But probably none of them is written in java. They are native linux apps.

Again: you CAN create nonui apps (jar) with b4j and you can run this apps/jars on any machine capable of running java apps. On windows/linux a JDK must be installed.
On Android it is not possible.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
to run a jar file the path to the java executeable must be known. I do not think that there is a JDK installed on my Device.

I do have termux installed.... I tried to call java from the console. No command java found.
How about this?
 
Upvote 0

JohnK

Active Member
Licensed User
Longtime User
Yes, right. But probably none of them is written in java. They are native linux apps.

Again: you CAN create nonui apps (jar) with b4j and you can run this apps/jars on any machine capable of running java apps. On windows/linux a JDK must be installed.
On Android it is not possible.
I was actually thinking about something related to this. If I was to create a NON-UI app using B4J, it would seem logical I could take the source, and compile using the JDK targeting android?

Regarding Termux, I don't want another dependency. There should be no need for such a dependency.

As for my examples, I also build full ROMs from source. Some or similar stand alone android apps are built as part of the ToyBox build (check your devices' /system/xbgin and/or /system/bin folders). I haven't explicitly checked if some are written in java, or all are C/C++, but there is no "Native Linux" programming language. There are device specific proprietary binaries (such as bootloader and hardware drivers), but the commands above and similar are not part of those; they are within the android source, somewhere. I am pretty sure busybox is written in C (here is the beep command source in C https://git.busybox.net/busybox/tre...e&id=be947c4d97c0dacb703a6f24dd813ff6dd3a33b6 which does not work on either of my devices) so would expect the same from ToyBox, but there is no reason in my mind that some parts or similar may not of, but could of been written in Java.

I think my best bet would be to bite the bullet and code then up using notepad (Java). I am only looking at some VERY simple features such as toasts & "beep" (triggered from the command line), so they shouldn't be much code nor complexity. And then compile them using the command line. Weird thing is that all examples I can find on the internet are for apps with an Activity.
 
Upvote 0
Top