5

Is it possible to start native android camera app that starts default camera instead of showing intent chooser and then start activity to get results?

Jan
  • 859
  • 7
  • 30

3 Answers3

3

You can start the Camera app by using a intent, like in: Android camera intent

You can set a specific class in your intent like this:
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
intent.setClassName("com.android.camera", "com.android.camera.Camera");

This will not show the intent-chooser and launch the default Camera-app.

Community
  • 1
  • 1
FrankkieNL
  • 711
  • 9
  • 22
  • 1
    This doesnot works. It gave error to register this activity in manifest and i did that as well. but still the problem is there – Jan May 27 '12 at 11:14
  • 1
    This will not work across different phones since many OEMs use their own camera with different class/package names. http://stackoverflow.com/questions/3748605/starting-video-camera-with-intent – Andrew G Oct 01 '12 at 18:32
  • **setClassName** doesn't work, without this line it works but if there are some 3rd party application like **Line Camera**, **Paper Camera** are installed in your phone above action will open a chooser. So how to open default camera without showing chooser? – Nauman Zubair Sep 27 '13 at 12:22
  • Check what the package and class of the camera-app is, and put that information in setClassName. – FrankkieNL Sep 27 '13 at 13:01
0
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);            
 startActivityForResult(intent, TAKE_PICTURE);
baronS
  • 1,074
  • 11
  • 11
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);
        } 

    } 

In Manifest

<uses-feature android:name="android.hardware.camera"/>
Parag Chauhan
  • 35,760
  • 13
  • 86
  • 95
  • This asks for chooser. I want to start native android camera only and i want to hide the chooser means it directly opens native camera application. – Jan Jun 11 '12 at 08:37