Friday, 11 September 2015

Using Camera

We set a imageView in the the android xml layout
and a button to capture image

In the onclick of the button we

Set uo an Intent to capture image
Intent intent= new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

after the we start activity of this Intent
startActivityForResult(intent,0);

but it must be noticed that its not just startActivity but StartActivity for Result
which mean that we will be able to capure the result

To Capture the result we will have to override a method called onActivityResult

We will recieve our image in bitmap format and for that we will create a bitmap object

We also create a global ImageView variable in our class and initialize that while we are in
 Oncreate


in the onActivityresult 
we put this code

Bitmap bm= (Bitmap) data.getExtras().get("data");
// gets the image of the result
iv.setImageBitmap(bm);




No comments:

Post a Comment