If you want to implement the ability to take photos in your own app, first add the permissions to the Androidmanifest.xml file:
<android:name= "Android.permission.CAMERA"/>
The way to start the camera is very simple, with intent access to Mediastore.action_image_capture
New1);
Once photographed and confirmed, the activity's Onactivityresult method is called, where the image data can be obtained.
Onactivityresult (intint resultcode, Intent data) { if (Requestcode = = 1) { if (ResultCode = = Result_ok) {= (Bitmap) Data.getextras (). Get ("Data") ; // can set bitmap to ImageView here } }}
In this way, you will find that the bitmap is very small, which is actually a thumbnail image of the picture taken.
If you want to get the original large image, the recommended way is to specify the file address of the picture before starting the camera, notify intent, and also remain in the member variable.
Then, in the Onactivityresult function, you can open the file directly.
The first piece of code makes the following modifications:
String Sfilefullpath = Environment.getexternalstoragedirectory (). GetAbsolutePath () + "/test.jpg"New new1);
[Android] using the camera in the app