I must have missed this message earlier. From what I understand, there are restrictions after Oreo on background execution. https://developer.android.com/about/versions/oreo/android-8.0-changesI have a strange problem: When I close both Total Commander and Termux via Task Manager, and then try to send a command to Termux via Termux service, I get the following error:although checkSelfPermission(termuxPermission) returns PackageManager.PERMISSION_GRANTED.Not allowed to start service Intent { act=com.termux.RUN_COMMAND flg=0x10000000 cmp=com.termux/.app.RunCommandService (has extras) }: app is in background uid null
My guess is that it happens because the Termux service isn't running when Termux itself isn't running. I have to start both Termux and Total Commander manually to be able to send commands from Total Commander to Termux.
https://stackoverflow.com/questions/47209662/error-app-is-in-background-uid-null
can you try using
Code:
am start-foreground-service
I believe I understand what you mean. I've been playing around with the button feature for a bit. you can actually pass the am start using the 'sh' functionaliy (at least in the 3.30 version) but it all has to be on one line. I cant actually confirm it yet because im not going to modify your app without proper permission, but the error i get (a truncated pop-up) matches what others get when trying the same thing through adb, namely that the RUN_COMMAND permissions are not granted. which is what i would expect and want. I've tried a lot of things but this is what seems to produce that message:That's not what I mean - what you describe would be from a PC via ADB.It's recommended to use the `am startservice` command
What I mean is the following: The user has created a button in Total Commander to execute a command via Termux. But after a reboot, Termux isn't running. The user presses the button and gets an error back.
in the parameters field of the send shell command all as one line:
Code:
am start-foreground-service --user 0 -n com.termux/com.termux.app.RunCommandService -a com.termux.RUN_COMMAND --es com.termux.RUN_COMMAND_PATH '/data/data/com.termux/files/usr/bin/top' --esa com.termux.RUN_COMMAND_ARGUMENTS '-n,5' --es com.termux.RUN_COMMAND_WORKDIR '/data/data/com.termux/files/home' --ez com.termux.RUN_COMMAND_BACKGROUND 'false' --es com.termux.RUN_COMMAND_SESSION_ACTION '0'
You could also try if that doesn’t work:
Disabling battery optimizations
Granting draw over permissions
Statistics: Posted by Tcrocks — 2025-01-08, 16:02 UTC