Android Camera Preview

I have a problem with the tutorial that I am following. I want to make an Android app with a camera preview, but so far I have not found a good tutorial that shows how to do this. Here is the tutorial link. I'm not quite sure if I can use the "camera with intent" set in the "camera preview"? What should I do?

Thank:)

+5
source share
3 answers

The following tutorials will help you.

http://www.vogella.com/articles/AndroidCamera/article.html

http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/graphics/CameraPreview.html

Call the built-in camera to have an image.

public class demo extends Activity {

Button ButtonClick;
int CAMERA_PIC_REQUEST = 1337; 


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    ButtonClick =(Button) findViewById(R.id.Camera);
    ButtonClick.setOnClickListener(new OnClickListener (){
        @Override
        public void onClick(View view)
        {
            Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
            // request code

            startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);

        }
    });

}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) 
{
    if( requestCode == 1337)
    {
    //  data.getExtras()
        Bitmap thumbnail = (Bitmap) data.getExtras().get("data");

          Now you have received the bitmap..you can pass that bitmap to other activity
          and play with it in this activity or pass this bitmap to other activity
          and then upload it to server.
    }
    else 
    {
        Toast.makeText(demo.this, "Picture NOt taken", Toast.LENGTH_LONG);
    }
    super.onActivityResult(requestCode, resultCode, data);
}
}
+17

CameraPreviewSample. , github , .

, , ( readme ), .

Google. Android Training Article .

+4

, , Android. MediaStore. ACTION_IMAGE_CAPTURE, Camera .

Below you can download the code, see the final output and a step-by-step explanation of the example:

https://abhiandroid.com/programming/camera

0
source

All Articles