Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run Android camera application from adb shell?

Tags:

android

shell

adb

How can I run android camera program from adb shell?
I know that I should use am but I do not know what command should I exactly enter

I used this:

am start -a android.intent.action.MAIN -n com.android.camera 

But it didn't work!

like image 254
Mohammad Razeghi Avatar asked Sep 13 '11 12:09

Mohammad Razeghi


2 Answers

Alternatively, you can start the camera in 2 other ways

  1. Image capture mode: adb shell "am start -a android.media.action.IMAGE_CAPTURE"
  2. Video capture mode: adb shell "am start -a android.media.action.VIDEO_CAPTURE"

Other information

  1. To focus: adb shell "input keyevent KEYCODE_FOCUS"
  2. To take a photo or start/stop recording: adb shell "input keyevent KEYCODE_CAMERA"

Other notes

f the keycode string e.g KEYCODE_CAMERA, does not work, lookup the constant value from the API description. Example: KEYCODE_CAMERA

KEYCODE_CAMERA: Added in API level 1
Constant Value: 27 (0x0000001b)
like image 146
Keo Malope Avatar answered Nov 09 '22 16:11

Keo Malope


  • Create a CameraActivity class.
  • Implement camera functionality there and add to AndroidManifest.xml file.
  • Then use following command:

    am start -a android.intent.action.MAIN -n [package-name].CameraActivity 
    

I hope this will solve your problem.

like image 27
Dibyendu Basu Avatar answered Nov 09 '22 16:11

Dibyendu Basu