some scripts or tasks can take a long time to run as termux emulates a linux machine, most things you can do in linux you should be able to do within termux. Some you would even want to run consecutively with other work you are doing. If a task is running and it gets destroyed before it is finished that could be problematic.I don't understand why Termux uses a service to accept commands, it just doesn't make any sense to me. They should just do what all other apps do, accept commands via Intent sent to the activity. This launches the activity when it isn't running yet, and sends a "new intent" event if the activity is already running.
so using Broadcast as a reciever is too short lived (max ~15s)
Activity is also not used because they can be sent to background and similarly be destroyed prematurely.
Termux manages, stores, and recieves shell commands even if app is in background and activity is not in foreground. Android currently requires a foreground service for running long term tasks. This provides a lot of flexibility in your termux scripts especially if you are using them to manage server tasks or performing complex multi-step file operations
ie. scanning video files for duplicates by comparing snapshots at a time that all videos share.
Statistics: Posted by Tcrocks — 2025-01-05, 17:37 UTC