I have two activites: one where I take a picture and another where it will display the photo.
On camera activity results I set a bitmap to the cached image as follows:
m.setImageBitmap(imageBitmap);
m.setDrawingCacheEnabled(true);
p=m.getDrawingCache();
And then when creating an intent for the new Activity I pass this bitmap:
Intent intent = new Intent(this, shopList.class);
intent.putExtra("data", p);
startActivity(intent);
And on the new activity I set the imageview I want to link to the new bitmap:
Bitmap p = (Bitmap) getIntent().getParcelableExtra("data");
ImageView m = (ImageView) findViewById(R.id.listA);
m.setImageBitmap(p);
But when running the app it will crash when trying to set the imageview to the new bitmap and gives the following error:
Attempt to invoke virtual method 'void android.widget.ImageView.setImageBitmap(android.graphics.Bitmap)' on a null object reference
I am not sure why its doing this as the initial camera activity results displays the photo correctly.
Any help is appreciated.
Edit: The XML for the second activity imageview I am trying to set is:
<ImageView
android:id="@+id/listA"
android:layout_width="97dp"
android:layout_height="90dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.019"
app:srcCompat="@mipmap/ic_launcher" />