I Inman Well-Known Member Licensed User Longtime User Dec 9, 2019 #1 Most camera apps have an option to take a photo when volume buttons are pressed. I am trying to implement a background service that will send Volume Down keypress when the camera app is open. Here is what I tried so far for testing. Create a service that has a SendInput object running inside a timer every 3 seconds SendInput.SendKeyCode(KeyCodes.KEYCODE_VOLUME_DOWN) is called inside the timer Before opening camera app, I can see this timer working as the device volume is decreasing. I also have a log message inside timer that confirms the same When Camera app is opened, I can see the log message indicating timer is executed but nothing is happening If I press the Volume button, the camera app takes a photo Theoretically if physical Volume button click takes a photo, the SendInput should also work. But it doesn't. The author of the library doesn't seem to be active anymore. So any idea why the Volume button click emulation is not working in camera app?
Most camera apps have an option to take a photo when volume buttons are pressed. I am trying to implement a background service that will send Volume Down keypress when the camera app is open. Here is what I tried so far for testing. Create a service that has a SendInput object running inside a timer every 3 seconds SendInput.SendKeyCode(KeyCodes.KEYCODE_VOLUME_DOWN) is called inside the timer Before opening camera app, I can see this timer working as the device volume is decreasing. I also have a log message inside timer that confirms the same When Camera app is opened, I can see the log message indicating timer is executed but nothing is happening If I press the Volume button, the camera app takes a photo Theoretically if physical Volume button click takes a photo, the SendInput should also work. But it doesn't. The author of the library doesn't seem to be active anymore. So any idea why the Volume button click emulation is not working in camera app?
Peter Simpson Expert Licensed User Longtime User Dec 9, 2019 #2 I'm not sure id this will work for you or not, but have you seen this link @Inman??? https://www.b4x.com/android/forum/threads/intercept-volume-button-press.28179/#post-163378 Upvote 0
I'm not sure id this will work for you or not, but have you seen this link @Inman??? https://www.b4x.com/android/forum/threads/intercept-volume-button-press.28179/#post-163378
I Inman Well-Known Member Licensed User Longtime User Dec 9, 2019 #3 Peter Simpson said: I'm not sure id this will work for you or not, but have you seen this link @Inman??? https://www.b4x.com/android/forum/threads/intercept-volume-button-press.28179/#post-163378 Click to expand... Thanks Peter but that example is about detecting volume button press. What I am trying to do is simulate volume button press by sending it's keycode. Upvote 0
Peter Simpson said: I'm not sure id this will work for you or not, but have you seen this link @Inman??? https://www.b4x.com/android/forum/threads/intercept-volume-button-press.28179/#post-163378 Click to expand... Thanks Peter but that example is about detecting volume button press. What I am trying to do is simulate volume button press by sending it's keycode.
Peter Simpson Expert Licensed User Longtime User Dec 9, 2019 #4 I was thinking that you could detect the button press and then handle the rest yourself, that's if there's no easier way to do what you want, as there's bound to be @Inman Upvote 0
I was thinking that you could detect the button press and then handle the rest yourself, that's if there's no easier way to do what you want, as there's bound to be @Inman
I Inman Well-Known Member Licensed User Longtime User Dec 9, 2019 #5 Peter Simpson said: I was thinking that you could detect the button press and then handle the rest yourself, that's if there's no easier way to do what you want, as there's bound to be @Inman Click to expand... Actually what I want to do is click a photo using camera app when certain conditions are satisfied. I don't need the actual picture file or anything; I just need to click the photo using camera app. Since there's no way to click the trigger button on another camera app, I thought the next possible solution will be to simulate volume button press. Upvote 0
Peter Simpson said: I was thinking that you could detect the button press and then handle the rest yourself, that's if there's no easier way to do what you want, as there's bound to be @Inman Click to expand... Actually what I want to do is click a photo using camera app when certain conditions are satisfied. I don't need the actual picture file or anything; I just need to click the photo using camera app. Since there's no way to click the trigger button on another camera app, I thought the next possible solution will be to simulate volume button press.