Call camera in Android to get pictures can be obtained in two ways, first of all by invoking system services to open the camera
Intent Intent = new Intent (mediastore.action_image_capture);
Startactivityforresult (Intent,requestcode);
The first method is to get the picture from the result returned by Startactivityforresult, as follows: if (RESULTCODE==RESULT_OK)
{
if (requestcode==req_1)
{
Bundle bundle = Data.getextras ();
Bitmap Bitmap = (Bitmap) bundle.get ("Data");
Iv.setimagebitmap (bitmap);
}
}< /span>
The second method, before invoking the service, sets the save path of the picture to be taken,
Path = Environment.getexternalstoragedirectory (). GetPath ();
Path + = "/" + "temp.png";
Intent Intent = new Intent (mediastore.action_image_capture);
Uri Photouri = uri.fromfile (new File);
Intent.putextra (Mediastore.extra_output,photouri);
Startactivityforresult (intent,req_2);
The picture is read in Onactivityresult, and in this case the resulting image is uncompressed.
if (requestcode==req_2)
{
FileInputStream FIS = null;
Try
{
fis = new FileInputStream (new File);
Bitmap Bitmap = Bitmapfactory.decodestream (FIS);
Iv.setimagebitmap (bitmap);
}catch (Exception e)
{
e.printstacktrace ();
}finally
{
Try
{
if (fis!=null)
fis.close ();
}catch (Exception e)
{
e.printstacktrace ();
}
}
}
Android Camera Call