I have an object, called Object_Assoc, this object is supposed to store bitmap images into its member variable o_memory. I call the helper function setO_memory, with the bitmap image to set as the parameter. However this is crashing my application. I create the bitmap image, by using the android camera API.
public void takePicture(View view) {
Intent imageTakeIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (imageTakeIntent.resolveActivity(getPackageManager()) != null) {
startActivityForResult(imageTakeIntent, REQUEST_IMAGE_CAPTURE);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
Bundle extras = data.getExtras();
Bitmap imageBitmap = (Bitmap) extras.get("data");
// Need to set image of Object here to object.
newObj.setO_memory(imageBitmap);
setContentView(R.layout.view_existing_obj_pop_up);
final ImageView mImageView = findViewById(R.id.clickedObjImage);
// Write object to Palace File
listOfMyPalaces.writePalacesFile(MyPalaceDetail.this);
// Set image
mImageView.setImageBitmap(imageBitmap);
// Sets the current view back to the palace detail(Unsuccessful though)
setContentView(R.layout.activity_my_palace_detail);
// Resets the Dialog to include the image that has been taken with the camera
init();
initDraggingListening();
}
}
java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=101, result=-1, data=Intent { act=inline-data (has extras) }} to activity {memorypalace.palace14/memorypalace.palace14.MyPalaceDetail}: java.lang.NullPointerException: Attempt to invoke virtual method 'void memorypalace.palace14.classes.Object_assoc.setO_memory(android.graphics.Bitmap)' on a null object reference