[英]How can I run Android camera application from adb shell?
How can I run android camera program from adb shell? 如何从adb shell运行android camera程序?
I know that I should use am but I do not know what command should I exactly enter 我知道我应该使用am,但我不知道我应该确切输入什么命令
I used this: 我用这个:
am start -a android.intent.action.MAIN -n com.android.camera
But it didn't work! 但这没有用!
Alternatively, you can start the camera in 2 other ways 或者,您可以通过其他两种方式启动相机
adb shell "am start -a android.media.action.IMAGE_CAPTURE"
图像捕获模式: adb shell "am start -a android.media.action.IMAGE_CAPTURE"
adb shell "am start -a android.media.action.VIDEO_CAPTURE"
视频捕获模式: adb shell "am start -a android.media.action.VIDEO_CAPTURE"
Other information 其他资讯
adb shell "input keyevent KEYCODE_FOCUS"
要关注的是: adb shell "input keyevent KEYCODE_FOCUS"
adb shell "input keyevent KEYCODE_CAMERA"
拍摄照片或开始/停止录制: adb shell "input keyevent KEYCODE_CAMERA"
Other notes 其他注意事项
f the keycode string eg KEYCODE_CAMERA, does not work, lookup the constant value from the API description. 如果键码字符串(例如KEYCODE_CAMERA)不起作用,请从API描述中查找常量值。 Example: KEYCODE_CAMERA 示例: KEYCODE_CAMERA
KEYCODE_CAMERA: Added in API level 1
Constant Value: 27 (0x0000001b)
CameraActivity
class. 创建一个CameraActivity
类。 AndroidManifest.xml
file. 在那里实现相机功能,并添加到AndroidManifest.xml
文件。 Then use following command: 然后使用以下命令:
am start -a android.intent.action.MAIN -n [package-name].CameraActivity
I hope this will solve your problem. 我希望这能解决您的问题。
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. 我想补充一下Keo Malope的回答,虽然IMAGE_CAPTURE和VIDEO_CAPTURE可能在大多数设备上都可以工作,但我遇到了它们无法按预期工作的情况。 In this case, we have two more constants that we can try: 在这种情况下,我们可以尝试另外两个常量:
adb shell am start -a android.media.action.STILL_IMAGE_CAMERA
adb shell am start -a android.media.action.VIDEO_CAMERA
在这里对我有用
adb shell am start -n com.mediatek.camera/com.android.camera.CameraActivity
You need to specify exact component name (name of activity). 您需要指定确切的组件名称(活动名称)。
am start -a android.intent.action.MAIN -n com.android.camera/.CameraEntry 开始-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. 它可以在我的设备(HTC Desire HD)上运行,但是我不能保证它可以在任何地方运行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.