Hi Dan! I was following the pattern proposed in Mark Murphy's book Advanced Android Development. Unfortuantely it appears that the static variable mechanism for state doesn't work as the BroadcastReceiver can run in a separate DalikVM than the Service, making the static variable instances completely different.
This intrigued me: > * So, my BroadcastReceiver keeps a static Map<Long, WakeLock> ofWakeLocksit > creates when onReceive is called. It creates a new > WakeLock for each call to onReceive, and generates a new unique ID > (hence the Long) for each one. The ID is sent as an Extra in the > Intent to the Service being fired. The Service, in onStart, creates > its own WakeLock, then sends a "release wakelock" Intent back to the > BroadcastReceiver with the same ID. When the BroadcastReceiver gets > that returned Intent, it releases the WakeLock stored in the map. > This method is a bit more complex than the public static, but does > allow the BroadcastReceiver and Service to reside in different > processes. Please let me know if this technique is harmful or bad in > some way. It seems to work for me. And indeed it does seem to work, but from the documentation: "A BroadcastReceiver object is only valid for the duration of the call to onReceive(Context, Intent). Once your code returns from this function, the system considers the object to be finished and no longer active." http://developer.android.com/reference/android/content/BroadcastReceiver.html This seems to indicate that the fact that the static Map is still in existence between broadcast calls is simply coincidence. Since I can find (or think of) no way to pass a WakeLock to any global or shared location for the BroadcastReceiver and Service both to use, I am stuck figiuring out how to make this work. I need to check more implementations out there and see what other people do. I'm in contact with Mark Murphy about this issue and we're trying to look through a few pattern examples and come up with one of our own. Cheers, bk -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

