Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

if you use Termux to host your service, then you can "Acquire wakelock" to keep it available with the screen off. That's an action-button attached to the Termux notification, and I believe also the main reason Termux has a notification (to trick android into not background-killing it).

I have some quickstart notes here: https://ocv.me/termux/



From experience (not with Termux but persistent services in general) this partially works. The device will really throttle the CPU / network when the screen is off.

This means that your HTTP request instead of taking <200ms will now take 5s.

Or at least, this is my experience with a custom app I wrote for Android 13+ running on a Xiaomi device (veux).

As soon as you turn on the screen (no need to unlock the device), the web server is immediately responsive as it should be


That's curious; maybe this is device/distro-specific? I've had good experience using this approach to transfer files to both my tablet (Samsung s2, lineage) and phone (pixel7, grapheneos).

Or maybe Termux is pulling some additional tricks to avoid this issue?


It could be that my device is heavily throttling for saving battery: the device battery (even with this long-running service) lasts multiple weeks on a single charge.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: