multithreading - Android - Wakelock thread is not turning the screen on -
i having trouble wakelocks. basically, had wakelock running in timer thread, doinbackground of asynctask entire duration of app (it background app taking performance measurements). decided want screen wakeup every 10 minutes or second or so. created class extending asynctask , put code below it's doinbackground, screen doesn't turn on. should note start thread , 2 other threads asynctask doinbackground methods oncreate.
here new inner class doing waking up: supposed wake phone screen every 10 minutes bit until other 2 background threads set booleans true.
private class wakeup extends asynctask<void, void, void> { @override protected void doinbackground(void... arg0) { powermanager pm = (powermanager) getsystemservice(context.power_service); powermanager.wakelock wl = pm.newwakelock(powermanager.screen_bright_wake_lock, getclass().getname()); do{ try { thread.sleep(wakeup_every); //600000ms } catch (interruptedexception e) { e.printstacktrace(); } wl.acquire(); try { thread.sleep(1000); } catch (interruptedexception e) { e.printstacktrace(); } wl.release(); }while(!timecompleted || !transfercompleted); return null; } }
you've forgotten tell wake lock turn on screen using acquire_causes_wakeup flag. per documentation:
normal wake locks don't turn on illumination. instead, cause illumination remain on once turns on (e.g. user activity). flag force screen and/or keyboard turn on immediately, when wakelock acquired. typical use notifications important user see immediately.
see acquire_causes_wakeup more details :d
Comments
Post a Comment