Yogesh D
Yogesh D

Reputation: 1681

Unable to display the stored image in imageview?

    Intent i = getIntent();
    mPathString = i.getStringExtra("imagepathstring");
    Toast.makeText(getApplicationContext(), mPathString, Toast.LENGTH_LONG).show();

    try {
        Bitmap temp = BitmapFactory.decodeFile(mPathString);
        capturedImageView.setImageBitmap(temp);
    } catch (Exception e) {
        // TODO: handle exception
    }

Here the code runs perfectly and even the toast displays the correct path of the image that I am storing on external storage. But still the image does not appear on the imageview. And if i remove the try and catch block surrounding bitmap object then my app fails with nullpointer exception. Can any one help to figure out what mistake I have done..? Thank you

Upvotes: 0

Views: 88

Answers (4)

user2323471
user2323471

Reputation: 85

please set your capturedImageView with layout imageview. i think then it works fine.

ImageView capturedImageView;
capturedImageView=(ImageView)findViewById(R.id.capturedImageView);

Upvotes: 2

Jake JediMastr Ellis
Jake JediMastr Ellis

Reputation: 279

What is the path you are using, and how are you generating it? It may not be exactly right.

Ah, and Roman Black may be right.

Upvotes: 0

Roman Black
Roman Black

Reputation: 3497

Check that you have initialized you capturedImageView. I think that your capturedImageView is null.

Upvotes: 2

Digvesh Patel
Digvesh Patel

Reputation: 6533

 mPathString = i.getExtra.getString("imagepathstring");

Upvotes: 0

Related Questions