Monday, October 22, 2012

[android-developers] Re: Android cuts off HttpURLConnection when screen timeout occurs.

You may want to rethink your network strategy; unless your app clearly requires constant network activity, you would do well to heed the system's default peripheral-sleep policies. Nothing ticks off users more than apps that kill battery by insisting that they remain active when the phone's not being used.

On Sunday, October 21, 2012 6:20:53 AM UTC-7, LouieLiu wrote:
The app I am writing uses a Streaming (REST) api that opens a HttpURLConnection and listens to a response from a server.
I use IntentService for this function so it runs in the background.
When my LG phone (ICS 4.03) goes dark (screen timeout), it terminates the connection. But it works fine on my ASUS tablet (ICS 4.03)
and will continue to accept more responses from the server and process the data.

So I wrote a small app which uses a timer to make a Http request every 30 seconds and then gets a response from the server.
For the LG phone, this app will continue to function as long as the screen is on, but when the screen times out, it will stop the activity (timer)
but it will resume making Http request when the screen is back on.
But for the ASUS tablet the app will continue to make Http request continuously even when the screen time out occurs.

Are there settings that I am not aware of that allow opened network connections to remain open and activities to continue to function when
the screen times out?

Thanks



--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment