Reputation: 3898
I am facing with the NullpointerExcetion while putting image in Bitmap. I am getting Image from SD card.
Uri path = android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
imageFile = new File(getRealPathFromURI(path));
if(imageFile.exists()){
Bitmap myBitmap = BitmapFactory.decodeFile(imageFile.getAbsolutePath());
ImageView myImage = (ImageView) findViewById(R.id.imageView1);
myImage.setImageBitmap(myBitmap);
}
Upvotes: 0
Views: 88
Reputation: 6905
If you are in an Activity, check if imageView1
is in the layout you passed to setContentView
method.
If you are using a fragment or have inflated programmatically a layout, then use view.findViewBy(R.id.imageView1)
instead
Upvotes: 0
Reputation: 25873
Wild guess: myImage
is null
. Check that you're importing the correct R
.
Upvotes: 2