I have the same problem. I can make the screen stay on, but if I use partial tracking lock and the screen is off, my onFinish function is not called until the screen is turned on.
You can check your wake lock by using mWakeLock.isHeld (), first of all, to make sure you get it. The easiest way is to add this to the code, set a debug breakpoint in it, and then check it.
In my case, I get this, but the partial track lock seems to do nothing. Here is my working code to lock the screen.
protected void setScreenLock(boolean on){ if(mWakeLock == null){ PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ON_AFTER_RELEASE, TAG); } if(on){ mWakeLock.acquire(); }else{ if(mWakeLock.isHeld()){ mWakeLock.release(); } mWakeLock = null; } }
ADDITION:
Users of Droid Eris and DROID tell me that this does NOT work on their devices, although it works fine on my G1. What device are you testing on? I think it could be an Android bug.
Brock Tice Jan 31 '10 at 2:10 2010-01-31 02:10
source share