gpt4 book ai didi

android - 有 Intent 地启动摄像机

转载 作者:太空狗 更新时间:2023-10-29 15:49:30 25 4
gpt4 key购买 nike

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

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。

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

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

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

最佳答案

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

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

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

这是用于在视频模式下调用相机应用程序的 Intent 。

关于android - 有 Intent 地启动摄像机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3748605/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com