I'm getting this error after the permission was allowed and the activity was recreated.
I/AppCompatDelegate: The Activity's LayoutInflater already has a Factory installed so we can not install AppCompat's
W/EGL_emulation: eglSurfaceAttrib not implemented
W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0x9e23f960, error=EGL_SUCCESS
W/System.err: java.io.IOException: open failed: EACCES (Permission denied)
W/System.err: at java.io.File.createNewFile(File.java:939)
W/System.err: at java.io.File.createTempFile(File.java:1004)
and
E/AndroidRuntime: java.lang.NullPointerException: file
E/AndroidRuntime: at android.net.Uri.fromFile(Uri.java:452)
The code for asking for permission is:
if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED ||
ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, 1);
}
After the crash when I start the app I do not see the permission dialog and everything works fine, I can open the Camera with intent. I'm using Emulator. Nexus 5 API 23.