Strange behaviour while using RUN_COMMAND Intent #3640
-
Hello This is my first post here and I would like to narrate a strange incident... I am the developer of an app which is a Terminal App Launcher. You can view it on GitHub here: https://github.com/coderGtm/yantra-app-launcher. What's relevant is that it has a But everytime Termux was not in the background or not opened recently, the command failed with error which stated Unable to start service Intent for RUN_COMMAND. App is in background Recently, I enabled wakelock for a termux session and tried using the Fast forward 2 days, I did not open termux in these 2 days even once. Now when I used the termux command with no wakelock and app also not in background for 2 days, the command works perfectly...not once, not twice but everytime.... I failed to understand the mechanism behind this strange incidents. I guess it's some trust issues with Android and Termux, as when I once granted wakelock permission to termux, Android started trusting termux and let it open from background. I am asking this because I need to give a proper solution to users of my app who want to use termux also from my app but it's too hard to set up for them with such kind of strange issues! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
It might be related to #3338 (comment) You can try If termux app was started two days ago and its foreground service notification remained, then it will still be considered a foreground app. Also foreground state might stay for a while after app is moved to background if it was opened. Force close termux app first to do testing. |
Beta Was this translation helpful? Give feedback.
Ah, when you enabled a wakelock in termux, it would have asked to be exempted from battery optimizations (
REQUEST_IGNORE_BATTERY_OPTIMIZATIONS
), that would be why error is not triggering any more. Draw over apps permission should have same effect. Could revoke it fromAndroid Settings
->Apps
->Termux
->Advanced
->Battery
->Battery optimizations
->Termux
->Don't optimize
. Wakelock permission (WAKE_LOCK
) itself is automatically granted.https://developer.android.com/guide/components/foreground-services#background-start-restriction-exemptions