J jimseng Active Member Licensed User Longtime User Aug 11, 2023 #1 Hello. I have an application that communicates with a Raspberry pi using Bluetooth serial. I have a routine on the Pi that sends a (serial) message to report a task is complete and my B4a app receives the message and vibrates the phone (a long vibrate) so I can tell when the task is complete even if the phone is in my pocket. However if the task take long enough for my screen to turn off I don't get the vibrate alert. Using: B4X: Copy Dim awake As PhoneWakeState awake.KeepAlive(True) My phone screen turns on but only to the lock screen, not the application and the vibrate doesn't happen, even though it is part of the same subroutine that wakes the phone. I don't really need to look at the phone, just feel the vibration. Any suggestions?
Hello. I have an application that communicates with a Raspberry pi using Bluetooth serial. I have a routine on the Pi that sends a (serial) message to report a task is complete and my B4a app receives the message and vibrates the phone (a long vibrate) so I can tell when the task is complete even if the phone is in my pocket. However if the task take long enough for my screen to turn off I don't get the vibrate alert. Using: B4X: Copy Dim awake As PhoneWakeState awake.KeepAlive(True) My phone screen turns on but only to the lock screen, not the application and the vibrate doesn't happen, even though it is part of the same subroutine that wakes the phone. I don't really need to look at the phone, just feel the vibration. Any suggestions?
Erel B4X founder Staff member Licensed User Longtime User Aug 13, 2023 #2 How are you triggering the vibration? You should do it with a high importance notification. You can make your app show above the lock screen with: https://www.b4x.com/android/forum/threads/unlock-password-locked-screen.14870/post-84636 Upvote 0
How are you triggering the vibration? You should do it with a high importance notification. You can make your app show above the lock screen with: https://www.b4x.com/android/forum/threads/unlock-password-locked-screen.14870/post-84636
J jimseng Active Member Licensed User Longtime User Aug 13, 2023 #3 I'm not running any of this in a service so I'm a bit confused as to whether it will receive any serial data when paused. However. Using B4X: Copy Dim awake As PhoneWakeState awake.KeepAlive(True) turns the screen on to the lock screen. Using: B4X: Copy Dim r As Reflector r.Target = r.GetActivity r.Target = r.RunMethod("getWindow") r.RunMethod2("addFlags", 6815872, "java.lang.int") doesn't, although the phone then stays on once I have unlocked it myself. And I am using: B4X: Copy Dim pv As PhoneVibrate pv.Vibrate(1000) to vibrate the phone currently. Given that the awake.KeepAlive turns the screen on it suggests to me that my subroutine is getting called (from AStream_NewData) I can use the keepalive to keep the screen on dim until the event has occurred, which is fine, but I want to try and learn a better way. I'll look at high importance notification but any pointers would be appreciated. Upvote 0
I'm not running any of this in a service so I'm a bit confused as to whether it will receive any serial data when paused. However. Using B4X: Copy Dim awake As PhoneWakeState awake.KeepAlive(True) turns the screen on to the lock screen. Using: B4X: Copy Dim r As Reflector r.Target = r.GetActivity r.Target = r.RunMethod("getWindow") r.RunMethod2("addFlags", 6815872, "java.lang.int") doesn't, although the phone then stays on once I have unlocked it myself. And I am using: B4X: Copy Dim pv As PhoneVibrate pv.Vibrate(1000) to vibrate the phone currently. Given that the awake.KeepAlive turns the screen on it suggests to me that my subroutine is getting called (from AStream_NewData) I can use the keepalive to keep the screen on dim until the event has occurred, which is fine, but I want to try and learn a better way. I'll look at high importance notification but any pointers would be appreciated.
Erel B4X founder Staff member Licensed User Longtime User Aug 14, 2023 #4 jimseng said: I'm not running any of this in a service Click to expand... You don't need a service but you do need to use B4XPages. Upvote 0
jimseng said: I'm not running any of this in a service Click to expand... You don't need a service but you do need to use B4XPages.
J jimseng Active Member Licensed User Longtime User Aug 14, 2023 #5 That's good news. I am using b4xpages. Upvote 0