just_another_coder
just_another_coder

Reputation: 1166

Android HttpPost socket timeout when android goes to sleep in background service

I have an android app that uses a background service for uploading data.

When we go upload data, everything works fine. Even when we make the display sleep, everything works.

However, this was while we were connected to Eclipse via USB. Once we disconnected the device, started to send the data and made the screen 'sleep,' we got a socket timeout exception.

Is there a special setting in the Service I need to make to allow it to continue to send data when the display sleeps?

Upvotes: 2

Views: 1241

Answers (1)

CommonsWare
CommonsWare

Reputation: 1007322

Is there a special setting in the Service I need to make to allow it to continue to send data when the display sleeps?

You need to hold a WakeLock. And, if you are connected via WiFi, you will need to hold a WifiLock.

Upvotes: 3

Related Questions