A Albert Lin Member Licensed User Longtime User Oct 13, 2016 #1 Dear all I would like to run some function after press volume button while screen off. Could anyone be kind to guide me how to do that? Thanks in advance. Best Regards Albert Lin
Dear all I would like to run some function after press volume button while screen off. Could anyone be kind to guide me how to do that? Thanks in advance. Best Regards Albert Lin
Erel B4X founder Staff member Licensed User Longtime User Oct 13, 2016 #2 You can try to intercept the VOLUME_CHANGED event: https://www.b4x.com/android/forum/threads/intercept-volume-button-press.28179/#post-163378 It will probably not fire when the screen is off. Upvote 0
You can try to intercept the VOLUME_CHANGED event: https://www.b4x.com/android/forum/threads/intercept-volume-button-press.28179/#post-163378 It will probably not fire when the screen is off.
A Albert Lin Member Licensed User Longtime User Oct 13, 2016 #3 Erel said: You can try to intercept the VOLUME_CHANGED event: https://www.b4x.com/android/forum/threads/intercept-volume-button-press.28179/#post-163378 It will probably not fire when the screen is off. Click to expand... Is there any way to make it fire when the screen off? Upvote 0
Erel said: You can try to intercept the VOLUME_CHANGED event: https://www.b4x.com/android/forum/threads/intercept-volume-button-press.28179/#post-163378 It will probably not fire when the screen is off. Click to expand... Is there any way to make it fire when the screen off?
A Albert Lin Member Licensed User Longtime User Oct 13, 2016 #5 Erel said: Did you try it? Click to expand... I did try, but it didn't fire. Upvote 0
Erel B4X founder Staff member Licensed User Longtime User Oct 13, 2016 #6 Check this answer: http://stackoverflow.com/a/15841187/971547 Upvote 0
A Albert Lin Member Licensed User Longtime User Oct 13, 2016 #7 Erel said: Check this answer: http://stackoverflow.com/a/15841187/971547 Click to expand... Thank you very much for the suggestion Upvote 0
Erel said: Check this answer: http://stackoverflow.com/a/15841187/971547 Click to expand... Thank you very much for the suggestion
A Albert Lin Member Licensed User Longtime User Oct 14, 2016 #8 Erel said: Check this answer: http://stackoverflow.com/a/15841187/971547 Click to expand... Dear Erel It does work. Thanks. Code: Sub BR_OnReceive(Action As String, Extras As Object) gVibrate.Vibrate (390) ToastMessageShow(Action,False) End Sub but from the "Action" parameter, I couldn't know which key is pressed. How to know Volume_up or Volume_down is pressed? Upvote 0
Erel said: Check this answer: http://stackoverflow.com/a/15841187/971547 Click to expand... Dear Erel It does work. Thanks. Code: Sub BR_OnReceive(Action As String, Extras As Object) gVibrate.Vibrate (390) ToastMessageShow(Action,False) End Sub but from the "Action" parameter, I couldn't know which key is pressed. How to know Volume_up or Volume_down is pressed?
sirjo66 Well-Known Member Licensed User Longtime User May 28, 2017 #9 Erel said: Check this answer: http://stackoverflow.com/a/15841187/971547 Click to expand... I'm sorry to re-open this old thread but I have the same problem and I don't understand what is the right way. In the link above I don't find the solution, I find "... because broadcast receiver not work when screen light off ...", so I don't understand if it works or not when screen is off Are you using BroadcastReceiver library ?? Do it works also when screen is off ?? Can you post a little code ?? Many thanks Sergio Upvote 0
Erel said: Check this answer: http://stackoverflow.com/a/15841187/971547 Click to expand... I'm sorry to re-open this old thread but I have the same problem and I don't understand what is the right way. In the link above I don't find the solution, I find "... because broadcast receiver not work when screen light off ...", so I don't understand if it works or not when screen is off Are you using BroadcastReceiver library ?? Do it works also when screen is off ?? Can you post a little code ?? Many thanks Sergio
Erel B4X founder Staff member Licensed User Longtime User May 29, 2017 #10 It will not work when the screen is off. Upvote 0
sirjo66 Well-Known Member Licensed User Longtime User May 29, 2017 #11 Is there a solution ?? Upvote 0
Erel B4X founder Staff member Licensed User Longtime User May 29, 2017 #12 It might be possible with a process that is running in the background all the time. Upvote 0