I'm using NanoHTTPD to present a web server in an android app. I'm using a wifi lock to keep the network alive, and a CPU lock to keep the cpu awake, and keeping it running via a foreground service so that it should never die.
What i'm finding is that it'll be accessible from other devices for half an hour, and then not accessible for half an hour. Whenever it becomes inaccessible, I can open safari on the android device and browse to 0.0.0.0:30000 and verify that the server is indeed running. And i also check to make sure the wifi is connected which it appears to be.
Any suggestions of where to look?
I don't know the exact reason why it's stop working. There are ways to keep service running but try this line of code in your activity onCreate if this can help you out
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With