I just noticed that you are performing a setReferenceCounted(false).
I think you will find that the WakeLock is never released, or not
released properly.


On Dec 11, 6:06 am, MrChaz <[email protected]> wrote:
> The code I'm using has a static method in the service I'm about to
> start that creates a wake lock that I then reference from within the
> started service.
> I took it from a discussion about WakeLocks in here and it seems to
> work.
>
>         private static PowerManager.WakeLock_wakeLock = null;
>
>         synchronized public static PowerManager.WakeLockgetLock(Context
> context) {
>                 if (_wakeLock == null) {
>                         //Log.i("DownloadService", "CreatingwakeLock");
>                         PowerManager 
> mgr=(PowerManager)context.getSystemService
> (Context.POWER_SERVICE);
>
>                         
> _wakeLock=mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
>                                                                               
>                                   "my worker wake lock");
>                         _wakeLock.setReferenceCounted(false);
>                 }
>
>                 return(_wakeLock);
>         }
>
> On Dec 11, 12:03 am, BK <[email protected]> wrote:
>
>
>
> > I think I may have found an issue within the
>
> > My understanding is that to properly hold a device awake after an
> > alarm is triggered you have to aquire aWakeLockin the onReceive()
> > event, call a Service, then perform the work in the Service, releasing
> > the lock within the Service when complete.
>
> >http://groups.google.com/group/android-developers/browse_thread/threa...
>
> >http://www.mail-archive.com/[email protected]/msg66...
>
> > This pattern can also be found in the CommonWare Advanced Android
> > Development book.
>
> > I tried this, but I found that the AlarmManager, when calling the
> > BroadcastReceiver, runs on a separate PID than the IntentService when
> > started from the BroadcastReceiver's onReceive() event.  This makes
> > the static variable on the lock manager.
>
> > I tried this, and my logs indicate that the PID is definately not the
> > same, and my understanding is that the DalikVM instances act like a
> > standard JVM, whereby objects and variables are no shared between
> > JVMs.
>
> > Furthermore, since theWakeLockis not serializable, there is really
> > no way to pass the reference to the lock via an "extra" in the Intent.
>
> > Has anyone else seen this pattern work or fail?  I have an example
> > project (with compiled APK) if you'd like to test it yourself, where
> > shall I post this?  I have tested this on the emulator on versions 1.6
> > and 2.0.- Hide quoted text -
>
> - Show quoted text -

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

Reply via email to