Java – android studio cannot display images in ImageView

android studio cannot display images in ImageView… here is a solution to the problem.

android studio cannot display images in ImageView

Global variables

static final int CAMERA_REQUEST = 1;
ImageView imageview;
Bitmap bitmap;

When created:

protected void onCreate(Bundle savedInstanceState) {


imageview = findViewById(;

onclick listener and intent:

Button take_photo_btn = findViewById(;
take_photo_btn.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v) {
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        startActivityForResult(intent, CAMERA_REQUEST);

This is the result of the activity:

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

if (requestCode == CAMERA_REQUEST && requestCode == RESULT_OK) {
        Bundle extras = data.getExtras();
        bitmap = (Bitmap) extras.get("image");

After taking a photo, I don’t see it in ImageView, what is the problem?


If you are using Marshmallow, you must implement runtime permissions for the camera used in Android.

For more details, visit this link

Related Problems and Solutions