Driver.pressKeyCode(AndroidKeyCode.KEYCODE_CAMERA) code does not work


It does not select the camera icon…

Has anyone had same issue before

Thank you!

What does it say in the appium server log?

I think this log refers to the camera icon… Thank you!

info: [debug] Pushing command to appium work queue: [“pressKeyCode”,{“keycode”:4,“metastate”:null}]

info: [debug] [BOOTSTRAP] [debug] Got data from client: {“cmd”:“action”,“action”:“pressKeyCode”,“params”:{“keycode”:4,“metastate”:null}}
info: [debug] [BOOTSTRAP] [debug] Got command of type ACTION
info: [debug] [BOOTSTRAP] [debug] Got command action: pressKeyCode
info: [debug] [BOOTSTRAP] [debug] Returning result: {“status”:0,“value”:true}
info: [debug] Responding to client with success: {“status”:0,“value”:true,“sessionId”:“5c0c5172-234c-4461-bde8-c3574d95ee31”}

I think it depends on the device you are using.

I have an LG in here and using adb shell input keyevent 27 doesn’t do anything if phone is outside camera, and if it is in camera it takes a photo. On other Motorola I have here, it enters camera and then changes from back camera to front camera without taking any picture.

thank you. I have samsung galaxy…

Please stop spamming forum by creating new topics about the same issue.

Open command line, write

adb shell input keyevent 27

If it doesn’t open camera, then you will have to do it other way. Maybe be sure that the camera icon is in home screen and then call home:

adb shell input keyevent 3

And next look for the icon that says Camera, something like (it may contain typos)


to open camera. Then you can try keyevent 27 again to try and see if it takes the photo and keyevent 4 to leave camera p.e.

thanks… I will remember that.

Hi All,

This will capture the photo on Perfecto Android:

String[] args = new String[] {"/bin/bash", “-c”, "adb shell input keyevent 27 "};
try {
new ProcessBuilder(args).start();
}catch (Exception e){

This will capture the photo on Local Android:


Thank you