有意图地启动摄像机 [英] Starting Video Camera with Intent

查看:23
本文介绍了有意图地启动摄像机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个非常小的应用程序,它只打开准备好视频的相​​机应用程序.我可以让我的代码在 Android 2.2 模拟器上运行,但它不能在我的设备上运行,Motorola Droid 1 stock 2.2 FRG22D.有什么想法我在这段代码上出错了吗?

I am writing a very small app that just opens the camera app ready for video. I am able to get my code to work on an Android 2.2 emulator, but it will not work on my device, Motorola Droid 1 stock 2.2 FRG22D. Any ideas where I went wrong on this code?

public class StartVid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

final int VIDEO = 1;

    Intent intent = new Intent();
    intent.setClassName("com.android.camera","com.android.camera.VideoCamera");
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    startActivityForResult(intent, VIDEO );
    finish();

看起来 ThorstenW 是正确的.如果我有足够的代表,我会赞成你的回答.从logcat中可以看到com.android.camera找不到并抛出了一个致命异常.下面是 Logcat.

It appears ThorstenW is correct. I would upvote your answer if I had enough rep. You can see from the logcat that com.android.camera could not be found and throws a fatal exception. Logcat below.

D/dalvikvm(1159):GC_EXTERNAL_ALLOC 在 66 毫秒内释放了 251 个对象/13456 字节I/ActivityManager(1086):开始活动:意图{act=android.intent.action.主猫=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.goatpen.Phobos.QSVideo/.StartVid }I/ActivityManager(1086):为活动com启动proc com.goatpen.Phobos.QSVideo.goatpen.Phobos.QSVideo/.StartVid:pid=483 uid=10092 gids={}

D/dalvikvm( 1159): GC_EXTERNAL_ALLOC freed 251 objects / 13456 bytes in 66ms I/ActivityManager( 1086): Starting activity: Intent { act=android.intent.action. MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.goatpen.Phobo s.QSVideo/.StartVid } I/ActivityManager( 1086): Start proc com.goatpen.Phobos.QSVideo for activity com .goatpen.Phobos.QSVideo/.StartVid: pid=483 uid=10092 gids={}

E/AndroidRuntime(483): java.lang.RuntimeException: 无法启动活动 ComponentInfo{com.goatpen.Phobos.QSVideo/com.goatpen.Phobos.QSVideo.StartVid}:和roid.content.ActivityNotFoundException:无法找到明确的活动类{com.android.camera/com.android.camera.VideoCamera};你有没有宣布这个活动是否在您的 AndroidManifest.xml 中?

E/AndroidRuntime(483):引起:android.content.ActivityNotFoundException:U无法找到显式活动类 {com.android.camera/com.android.camera.Vid电子相机};您是否在 AndroidManifest.xml 中声明了此活动?

推荐答案

您不会相信解决方案是多么容易.首先,motorola droid 的相机应用程序是 com.google.android.camera.这是标准的 android 2.2 包名称.我使用 adb 从/data/system/packages.xml 中提取文件以确认这一点.

You will not believe how easy the solution was. First the motorola droid's camera app is com.google.android.camera. This is the standard android 2.2 package name. I used adb to pull the file from /data/system/packages.xml to confirm this.

还有一个意图是在录像机模式下打开相机应用程序.INTENT_ACTION_VIDEO_CAPTURE.

Also there is an intent to open the camera app in video recorder mode. INTENT_ACTION_VIDEO_CAPTURE.

 Intent intent = new Intent("android.media.action.VIDEO_CAMERA");

这是用于在视频模式下调用相机应用程序的意图.

This is the intent to use to call the camera app in video mode.

这篇关于有意图地启动摄像机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆