Search code examples
androidbitmapnullpointerexceptionimageviewbitmapfactory

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


Solution

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