public void takePicture() throws NullPointerException {
  Intent takePictureIntent=new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
  if (takePictureIntent.resolveActivity(activity.getPackageManager()) != null) {
    File photoFile=Utils.createImageFile(context,dirName,imageName,imageType);
    if (photoFile != null) {
      cameraBitmapPath=photoFile.getAbsolutePath();
      takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.fromFile(photoFile));
      activity.startActivityForResult(takePictureIntent,REQUEST_TAKE_PHOTO);
    }
 else {
      throw new NullPointerException("Bitmap received from camera is null");
    }
  }
 else {
    throw new NullPointerException("Unable to open camera");
  }
}

public void takePicture ( ) throws NullPointerException { Intent takePictureIntent = new Intent ( MediaStore . ACTION_IMAGE_CAPTURE ) ; if ( takePictureIntent . resolveActivity ( activity . getPackageManager ( ) ) != null ) { File photoFile = Utils . createImageFile ( context , dirName , imageName , imageType ) ; if ( photoFile != null ) { cameraBitmapPath = photoFile . getAbsolutePath ( ) ; takePictureIntent . putExtra ( MediaStore . EXTRA_OUTPUT , Uri . fromFile ( photoFile ) ) ; activity . startActivityForResult ( takePictureIntent , REQUEST_TAKE_PHOTO ) ; } else { throw new NullPointerException ( "Bitmap received from camera is null" ) ; } } else { throw new NullPointerException ( "Unable to open camera" ) ; } }
initiate the existing camera apps
