This is the code i am using.

```
Intent takePictureIntent = new 
Intent(MediaStore.ACTION_IMAGE_CAPTURE);

if(takePictureIntent.resolveActivity(getPackageManager()) != null) {
    startActivityForResult(takePictureIntent, PICK_IMAGE_CAMERA1); 
 }

 protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    if (resultCode == RESULT_OK && data != null) {
    if (requestCode==PICK_IMAGE_CAMERA1){
    Bundle extras = data.getExtras();
    Bitmap imageBitmap = (Bitmap) extras.get("data");
    imageView.setImageBitmap(imageBitmap);
 }     
}
}

```

I am getting the following exception. 

```
java.lang.RuntimeException: Failure delivering result 
    ResultInfo{who=null, request=5, result=-1, data=Intent { act=inline-data (has extras) }} to activity {com.example.myapplication/com.example.myapplication.MainActivity}: java.lang.NullPointerException: url
        at android.app.ActivityThread.deliverResults(ActivityThread.java:4360)

```