How can I run Android camera application from adb

2019-02-01 13:24发布

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!

5条回答
我欲成王,谁敢阻挡
2楼-- · 2019-02-01 13:59

it works for me here

adb shell am start -n com.mediatek.camera/com.android.camera.CameraActivity
查看更多
一纸荒年 Trace。
3楼-- · 2019-02-01 14:06

I'd like to add to Keo Malope's answer that while IMAGE_CAPTURE and VIDEO_CAPTURE are likely to work on most devices, I have encountered cases where they don't work as expected. In this case, we have two more constants that we can try:

  • STILL_IMAGE_CAMERA
    • adb shell am start -a android.media.action.STILL_IMAGE_CAMERA
  • VIDEO_CAMERA
    • adb shell am start -a android.media.action.VIDEO_CAMERA
查看更多
你好瞎i
4楼-- · 2019-02-01 14:07
  • 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.

查看更多
The star\"
5楼-- · 2019-02-01 14:10

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)
查看更多
我命由我不由天
6楼-- · 2019-02-01 14:11

You need to specify exact component name (name of activity).

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

It is working on my device (HTC Desire HD), but I can't guarantee that it'll work everywhere.

查看更多
登录 后发表回答