启动默认的摄像头应用程序(不归路) [英] Launch default camera app (no return)

查看:96
本文介绍了启动默认的摄像头应用程序(不归路)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想启动默认的摄像头,但希望它像它从发射开始(即所产生的画面应该由摄像头应用程序可以存储用户的画廊,而不是回到了我的应用程序) 。如果我使用意图cameraIntent =新的意图(android.provider.MediaStore.ACTION_IM​​AGE_CAPTURE); ,相机应用程序使用确定重试? - 用户界面,不保存图像。我宁可不使用直接 com.android.camera 的意图,因为很多设备使用自定义的摄像头应用程序。我见过的股票gallery3d应用程序内使用别名实施 com.android.camera/.Camera ,但我不能保证每个$​​ P $ P-装制造商相机应用来实现的。

I'd like to launch the default camera, but want it to act like it was started from the launcher (i.e. the resulting picture should be stored by the camera app to the user's gallery, rather than being returned to my app). If I use Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);, the camera app uses the "OK? Retry?"-UI and doesn't save the picture. I'd rather not use a "direct" com.android.camera intent, because a lot of devices use custom camera apps. I've seen that the stock gallery3d-app uses an alias implementing com.android.camera/.Camera, but I'm not sure that every pre-loaded manufacturer camera app does this.

推荐答案

我现在已经实现了它是这样的:

I've now implemented it like this:

        Intent i = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
        try {
            PackageManager pm = mContext.getPackageManager();

            final ResolveInfo mInfo = pm.resolveActivity(i, 0);

            Intent intent = new Intent();
            intent.setComponent(new ComponentName(mInfo.activityInfo.packageName, mInfo.activityInfo.name));
            intent.setAction(Intent.ACTION_MAIN);
            intent.addCategory(Intent.CATEGORY_LAUNCHER);

            startActivity(intent); 
        } catch (Exception e){ Log.i(TAG, "Unable to launch camera: " + e); }

这篇关于启动默认的摄像头应用程序(不归路)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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