In order to get a clear image here, the returned data is not applicable, because this is the thumbnail image. The practice here is to specify where to save the picture before calling the camera, and then get the picture from the file by invoking the result function and the specified picture store path.
To start the camera's code:
1Intent =NewIntent (mediastore.action_image_capture);2File File =NewFile (environment.getexternalstoragedirectory ()3+ "/tempimage.jpg");4ImagePath =File.getabsolutepath ();5Uri Outuri = uri.fromfile (file);//gets the URI of the file6Intent.putextra (Mediastore.extra_output, Outuri);//Specify image storage location7Startactivityforresult (Intent, 2);
To call the camera, you need to add the appropriate permissions, as well as read and write access to the file:
1 <uses-permission android:name= "Android.permission.WRITE_EXTERNAL_STORAGE"/>2 < Uses-permission android:name= "Android.permission.READ_EXTERNAL_STORAGE"/>3 <uses-permission Android:name= "Android.permission.CAMERA"/>
The image is then read from the file and displayed through the Onactivityresult function:
1 New ImageView (this); 2 // The Imgepath here is the file that you just set up to save the image 3 image.setimagebitmap (Bitmapfactory.decodefile (ImagePath));
Call the camera to take a photo to get a picture