I am trying to take a photo from my phone and display it in an ImageView. I follow the steps of the web of Android Studio in which it indicates how to take a photo and show it but when showing it in the ImageView it comes out with very little quality. I do not understand where I can be failing
I leave the code:
Button photoButton = (Button) this.findViewById(R.id.button1);
photoButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
cameraIntent = new Intent (MediaStore.ACTION_IMAGE_CAPTURE);
if (cameraIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(cameraIntent, CAMERA_REQUEST);
}
}
});
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode,resultCode,data);
if(requestCode == CAMERA_REQUEST){
if(resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
imageBitmap = (Bitmap) extras.get("data");
imageView.setImageBitmap(imageBitmap); // photo with low quality
}
}
}
And the variables and constants;
private Intent cameraIntent;
private static final int CAMERA_REQUEST = 1888;
private Bitmap imageBitmap;
ImageView imageView;