Daniel,

The fact that the CPU is working and the phone is not asleep when the HttpUrlConnection starts doesn't mean it's going to still be that way by the time it finishes.... That's why you need the wakelock while the HttpUrlConnection is running.. to make sure it can finish. Just make sure to release the wakelock when it's done.

On 03/06/2010 8:41 AM, Daniel Lew wrote:
Well, I can tell you the process...

1. AlarmManager fires an intent to a Service.

2. That Service creates an HttpUrlConnection.

3. That connection fails every other time.

Not sure what more information you would need to be helpful.  I'm not
using a wakelock currently, but I guess I'm not sure why that's
necessarily relevant - I can see that the connection is being
attempted via my logging, so the device's CPU is on.  However, I will
try it and see if that fixes anything.

-Daniel

On Jun 2, 7:42 pm, Indicator Veritatis<mej1...@yahoo.com>  wrote:
I think you are going to have to be more informative than that to be
helpful. Not that it is your fault: the suggestion of 'wakelock' was a
good one. It is just that the online documentation for
PowerManager.WakeLock is not as thorough as that for, say for example,
Activity.

Why, as one example of a major omission, the documentation for the
acquire() method says, "Makes sure the device is on at the level you
asked when you created the wake lock", but no Constructor is
documented. Nor is there any mention of a Factory method. So how is
the user supposed to figure out HOW to ask for the level???

So since the documentation didn't mention it, I will mention it here:
the answer is in the class WakeLock is nested in(PowerManager), which
has the method 'newWakeLock()'. This is what does the creation
referred to so obliquely in the doc for 'acquire()'.

On Jun 2, 2:23 pm, Mike dg<vinb...@gmail.com>  wrote:



Are you using a wakelock?
On Jun 2, 4:10 pm, Daniel Lew<danle...@gmail.com>  wrote:>  I've run into a 
bizarre situation and I'm not sure how to solve it.
The app I'm working on has a regular pull update that occurs every so
often in the background.  When the phone is on, it works.  When the
phone is using wifi, it works.  However, if the phone is sleeping and
connected only to 3G, it only *sometimes* works.  Other times,
HttpUrlConnection.getInputStream() returns null (after a lengthy
timeout, though it's not based on any timeout setting...  it just
seems to randomly time out at some point).  There are no exceptions
thrown and no logs indicate any trouble, except that my connection
goes completely ignored.
Does anyone know why this might be happening?

--
Sincerely,

Brad Gies
-----------------------------------------------------------------------
Bistro Bot - Bistro Blurb
http://www.bgies.com
http://www.bistroblurb.com
http://www.bistrobot.com
-----------------------------------------------------------------------

Never doubt that a small group of thoughtful, committed people can
change the world. Indeed. It is the only thing that ever has - Margaret Mead

--
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

Reply via email to