Q qsrtech Active Member Licensed User Longtime User Mar 5, 2013 #1 Hi, I've found this code online, can anyone help make it work in b4a? It's suppose to be able to turn the screen back on if it's sleeping. Code: Copy PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "tag"); wl.acquire(); Thanks! John
Hi, I've found this code online, can anyone help make it work in b4a? It's suppose to be able to turn the screen back on if it's sleeping. Code: Copy PowerManager.WakeLock wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "tag"); wl.acquire(); Thanks! John
thedesolatesoul Expert Licensed User Longtime User Mar 5, 2013 #2 B4A already supports this: Basic4android - Phone Upvote 0
Q qsrtech Active Member Licensed User Longtime User Mar 5, 2013 #3 wake lock Hi, thank you for your suggestion. I'm already using the partiallock and keepalive but they only seem to prevent the screen from going to sleep. I'd like to prevent screen burn in by allowing the screen to go to sleep and then turn it back on when there is an event. I'm pretty sure it's possible cause I have an alarm app on my phone (4.03) which seems to do this. Any other solution? I'm pretty sure I need to use the type of wake lock I described earlier. From Android Developer: ACQUIRE_CAUSES_WAKEUP Normal wake locks don't actually turn on the illumination. Instead, they cause the illumination to remain on once it turns on (e.g. from user activity). This flag will force the screen and/or keyboard to turn on immediately, when the WakeLock is acquired. A typical use would be for notifications which are important for the user to see immediately. Upvote 0
wake lock Hi, thank you for your suggestion. I'm already using the partiallock and keepalive but they only seem to prevent the screen from going to sleep. I'd like to prevent screen burn in by allowing the screen to go to sleep and then turn it back on when there is an event. I'm pretty sure it's possible cause I have an alarm app on my phone (4.03) which seems to do this. Any other solution? I'm pretty sure I need to use the type of wake lock I described earlier. From Android Developer: ACQUIRE_CAUSES_WAKEUP Normal wake locks don't actually turn on the illumination. Instead, they cause the illumination to remain on once it turns on (e.g. from user activity). This flag will force the screen and/or keyboard to turn on immediately, when the WakeLock is acquired. A typical use would be for notifications which are important for the user to see immediately.
thedesolatesoul Expert Licensed User Longtime User Mar 5, 2013 #4 You are correct. It can probably be done with Reflection or a small library. My reflection skills are too rusty for this. Upvote 0
You are correct. It can probably be done with Reflection or a small library. My reflection skills are too rusty for this.
Q qsrtech Active Member Licensed User Longtime User Mar 5, 2013 #5 Almost there I've managed to get this code working: Code: Copy Dim obj1,obj2,obj3 As Reflector obj1.Target = obj1.GetContext obj2.Target = obj1.RunMethod2("getSystemService", "power", "java.lang.String") up until here, the value of "268435456"(ACQUIRE_CAUSES_WAKEUP) fails with an illegal argument exception, however if I use "1"(PARTIAL_WAKE_LOCK) it works fine Code: Copy obj3.Target = obj2.RunMethod3("newWakeLock","268435456", _ "java.lang.int","Mytag", "java.lang.String") Any pointers? UPDATE: changed it to "268435482" which adds "26" for a FULL_WAKE_LOCK Now to have the "lock screen" removed after waking up the device. Again, must be possible cause my alarm app does it. Last edited: Mar 5, 2013 Upvote 0
Almost there I've managed to get this code working: Code: Copy Dim obj1,obj2,obj3 As Reflector obj1.Target = obj1.GetContext obj2.Target = obj1.RunMethod2("getSystemService", "power", "java.lang.String") up until here, the value of "268435456"(ACQUIRE_CAUSES_WAKEUP) fails with an illegal argument exception, however if I use "1"(PARTIAL_WAKE_LOCK) it works fine Code: Copy obj3.Target = obj2.RunMethod3("newWakeLock","268435456", _ "java.lang.int","Mytag", "java.lang.String") Any pointers? UPDATE: changed it to "268435482" which adds "26" for a FULL_WAKE_LOCK Now to have the "lock screen" removed after waking up the device. Again, must be possible cause my alarm app does it.
stevel05 Expert Licensed User Longtime User Mar 5, 2013 #6 Check the documentation on Android Developers (google for that, sorry not on my pc). Lookup Powermanager. ------------------- Sent via Tapatalk Last edited: Mar 5, 2013 Upvote 0
Check the documentation on Android Developers (google for that, sorry not on my pc). Lookup Powermanager. ------------------- Sent via Tapatalk
Erel B4X founder Staff member Licensed User Longtime User Mar 6, 2013 #7 PowerManager.ACQUIRE_CAUSES_WAKEUP flag is set when you call PhoneWakeState.KeepAlive. Upvote 0