android-multipicker-library icon indicating copy to clipboard operation
android-multipicker-library copied to clipboard

NullPointerException

Open virengujariya opened this issue 7 years ago • 3 comments

Fatal Exception: java.lang.NullPointerException: Attempt to invoke virtual method 'int android.content.Context.checkPermission(java.lang.String, int, int)' on a null object reference
       at android.support.v4.content.ContextCompat.checkSelfPermission(ContextCompat.java:453)
       at com.kbeanie.multipicker.utils.FileUtils.checkForExternalStorageRuntimePermission(FileUtils.java:94)
       at com.kbeanie.multipicker.utils.FileUtils.getExternalFilesDirectory(FileUtils.java:32)
       at com.kbeanie.multipicker.core.threads.FileProcessorThread.getTargetDirectory(FileProcessorThread.java:494)
       at com.kbeanie.multipicker.core.threads.FileProcessorThread.getTargetLocationToCopy(FileProcessorThread.java:557)
       at com.kbeanie.multipicker.core.threads.FileProcessorThread.copyFileToFolder(FileProcessorThread.java:143)
       at com.kbeanie.multipicker.core.threads.FileProcessorThread.postProcess(FileProcessorThread.java:130)
       at com.kbeanie.multipicker.core.threads.FileProcessorThread.processFiles(FileProcessorThread.java:106)
       at com.kbeanie.multipicker.core.threads.FileProcessorThread.run(FileProcessorThread.java:79)
       at com.kbeanie.multipicker.core.threads.ImageProcessorThread.run(ImageProcessorThread.java:41)

using latest version of library

virengujariya avatar Jun 23 '17 19:06 virengujariya

@coomar2841 there is no way of reproducing this error on my side. Any idea under what circumstances this could happen?

virengujariya avatar Jun 23 '17 19:06 virengujariya

@virengujariya The activity or service where you are calling the library methods with context could be destroyed. So as context passed is null or became null by the time using it in checkPermission method, it is throwing that error.

sunnymopada avatar Jun 24 '17 04:06 sunnymopada

For Android 6.0 onwards you need to have storage permission before using this feature. So, I think this crash is related to permission not granted to you for storage. First, ask for the permission and then pick any of the media

vikoo avatar Aug 16 '17 19:08 vikoo