Android wake lock force close
Asked Answered
K

1

5

Hello I am trying to implement a wake lock for an application.

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "My Tag");

It seems to force close when defining the PowerManager shown in the code above. Whats going wrong?

Kataway answered 14/6, 2009 at 16:20 Comment(0)
C
7

Are you receiving this force close when running the code in the emulator on an actual device?

Have you set breakpoints in eclipse to verify that the getSystemService() call is what is causing the problem?

In eclipse when the force close occurs does LogCat say anything about it?

Did you set

<uses-permission android:name="android.permission.WAKE_LOCK" />

in the manifest?

You could also try defining pm as final:

final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);

Let me know if any of this helps...

Certiorari answered 14/6, 2009 at 20:5 Comment(3)
Tried the "final" with no change :( and the correct permission is in place. I have had a look in the logcat but tbh I'm not to great a decoding it...Kataway
Does anything show up in Red in LogCat at the time of the force close? If so copy and paste the red lines here and I can try to help decipher itCertiorari
Thanks for your help. Someone @ google groups fixed it. groups.google.com/group/android-developers/browse_thread/thread/…Kataway

© 2022 - 2024 — McMap. All rights reserved.