Android returns an instance of the image function taken
- 2020-06-23 01:58:04
- OfStack
This article is an example of Android's ability to return pictures taken. Share to everybody for everybody reference. The details are as follows:
Step 1:
try {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, 0);
} catch (ActivityNotFoundException e) {
// Do nothing for now
}
Step 2:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
try {
if (requestCode != 0) {
return;
}
super.onActivityResult(requestCode, resultCode, data);
Bundle extras = data.getExtras();
Bitmap b = (Bitmap) extras.get("data");
//
//
ImageView a = (ImageView)findViewById(R.id.imageView1);
a.setImageBitmap(b);
//
/*
* Get image to image processing ...
*/
} catch (Exception e) {
// TODO: handle exception
System.out.println(e.getMessage());
}
}
Hopefully, this article has been helpful in your Android programming.