启动默认的摄像头应用程序(不归路)归路、应用程序、摄像头

由网友(Mawkish 自作多情)分享简介:我想启动默认的摄像头,但希望它像它从发射开始(即所产生的画面应该由摄像头应用程序可以存储用户的画廊,而不是回到了我的应用程序) 。如果我使用意图cameraIntent =新的意图(android.provider.MediaStore.ACTION_IM​​AGE_CAPTURE); ,相机应用程序使用确定重试? -...

我想启动默认的摄像头,但希望它像它从发射开始(即所产生的画面应该由摄像头应用程序可以存储用户的画廊,而不是回到了我的应用程序) 。如果我使用意图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); }
阅读全文

相关推荐

最新文章