I have Threads because when the Alarm triggers I want to do two
separate things, although they don't necessarily have to be at the
*same* time so I'll remove the Thread.

For the WiFi lock I'm acquiring and releasing two locks now. Is that
about right?

My WiFi lock looks like:

PowerManager mgr =
(PowerManager)context.getSystemService(Context.WIFI_SERVICE);
lockWifi = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
LOCK_NAME_WIFI);
lockWifi.setReferenceCounted(true);

Thanks

On Mar 24, 5:59 pm, Mark Murphy <mmur...@commonsware.com> wrote:
> AuxOne wrote:
> > The wi-fi lock sounds interesting, but I'd need it to work with the
> > cellular network as well. Can I lock both?
>
> Cellular data should be always on, if I understand correctly.
>
> > Within the doWakefulWork function I instantiate a class and call one
> > of its methods. It ultimately creates a new Thread to make the Socket
> > connection.
>
> Bzzzzt.
>
> > I guess that's the issue.
>
> Ding, ding, ding!
>
> :-)
>
> > Instead of releasing the lock at
> > the end of WakefulIntentService.onHandleIntent, could I pass the lock
> > into my Thread and release it from there?
>
> IntentService in general is not designed for you to fork other threads.
> Remember: the IntentService component will call stopSelf() as soon as
> onHandleIntent() returns, if there is no other Intent queued up to be
> processed.
>
> Since IntentService does its work (onHandleIntent()) in a background
> thread, I don't know why you're forking yet another thread. I'd just do
> the HTTP operations in doWakefulWork().
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://twitter.com/commonsguy
>
> Android Development Wiki:http://wiki.andmob.org

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

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to