Hi folks, I have a service with a coarse-grained LocationListener which needs to do network access in onLocationChanged(). This is done in a separate thread (to avoid blocking the UI thread) with a wakelock (to ensure that the device doesn't sleep when onLocationChanged() is finished).
This generally works fine. But in a small fraction of cases, when the device hasn't been used for a while, the network call fails with an IOException (specifically, an UnknownHostException). The failure continues even when the call is retried several times, spanning several minutes or even hours. I am positive that a stable internet connection is available, both via WIFI and 3G. I imagine that the WIFI may have switched off to preserve battery, but the 3G connection should still be available -- right? Here is an outline of the code from the LocationListener: @Override public void onLocationChanged(Location loc) { PowerManager pm = (PowerManager) getSystemService(POWER_SERVICE); Wakelock wakelock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, MyService.class.getName()); wakelock.acquire(); new Thread(new Runnable() { @Override public void run() { someBlockingInternetIO(); mWakeLockPostCheckins.release(); } }).start(); } Any idea why this does not work consistently? Any pointers would be greatly appreciated, as this issue is affecting a published app. Thanks and best regards, Michael. -- 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en