I set the lock using wl.acquire() . It works great. I need this lock while waiting for my application to live, so the release() call can only be made when the application is left.
wl.acquire()
release()
Do I need to call release() somewhere? For example, in onStop() ? I would say no, but I'm not sure.
onStop()
Thanks A.
Besides the other helpful answers you already received, I just found this interesting answer on how to make the screen , maybe you will find it useful if you really do not need tracking lock.
if you link to these 2 pages:
http://developer.android.com/reference/android/os/PowerManager.html
http://developer.android.com/reference/android/os/PowerManager.WakeLock.html#release ()
You must release the tracking lock as soon as you can: therefore, if your application closes / pauses its release!
Also, a word of advice, make sure you need a tracking lock when you need it and for a long time.
in my case, I only put it on the game screen to avoid the userβs screen going black thinking (since this opengl application only takes a few seconds to fully load), but in other views I release it.
Trust me when I say that annoying the user to end up with an empty battery, because the application forced itself to stay awake.
as long as my application works how many actions does your application have? you can release it in onDestroy () of the last action that is called by the activitymanager agent.
And yes, you must release the lock, especially if you intend to maintain the brightness of the screen to avoid battery drain.
Source: https://habr.com/ru/post/1337109/More articles:How to make 3D graphics in Python? - pythonRails: sort by state in database - sortingAndroid - Downloading data from the Internet >> catch connection errors - androidLinking libraries containing circular references in GCC - gcccase-insensitive regular expression - c #How to work with different screen resolutions in CSS? - htmlC # threads and sync - multithreadingworkspace in tfs - tfsHow to programmatically trigger a click event on a specific grid line in JqGrid - javascriptHow to sum a participant by seq ? - f #All Articles