Null pointer Exception on file- URI?

后端 未结 4 1155
感动是毒
感动是毒 2020-12-11 05:19

In my app a capture button is there to capture an image using device camera,so I have used a method captureImage() on the click event of that button.When I click the button

4条回答
  •  醉酒成梦
    2020-12-11 06:01

    getOutputMediaFile(type) returns null.

     public Uri getOutputMediaFileUri(int type) {
        return Uri.fromFile(getOutputMediaFile(type));
    }
    

    You are returning here:

    // Create the storage directory if it does not exist
    if (!mediaStorageDir.exists()) {
        if (!mediaStorageDir.mkdirs()) {
            Log.d(TAG, "Oops! Failed create "
                    + Config.IMAGE_DIRECTORY_NAME + " directory");
            return null;
        }
    }
    

    Have you added the following permission

    
    

    to your manifest?

提交回复
热议问题