启动Native Camera而不显示选择器

时间:2012-05-23 11:06:10

标签: android

是否可以启动原生Android相机应用程序启动默认相机而不是显示意图选择器,然后启动活动以获得结果?

3 个答案:

答案 0 :(得分:3)

您可以使用意图启动相机应用,例如: Android camera intent

你可以在你的意图中设置一个特定的类,如下所示:
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
intent.setClassName("com.android.camera", "com.android.camera.Camera");

这不会显示意图选择器并启动默认的Camera-app。

答案 1 :(得分:0)

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);            
 startActivityForResult(intent, TAKE_PICTURE);

答案 2 :(得分:0)

imageView = (ImageView)findViewById(R.id.imageView1);
        Button photoButton = (Button)findViewById(R.id.button1);
        photoButton.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
                startActivityForResult(cameraIntent, CAMERA_REQUEST);
            }
        });
    }

    protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
        if (requestCode == CAMERA_REQUEST) { 
            Bitmap photo = (Bitmap) data.getExtras().get("data");
            imageView.setImageBitmap(photo);
        } 

    } 

在清单中

<uses-feature android:name="android.hardware.camera"/>
相关问题