I need to create a temporary image file for my camera to write it over while it is in WebView.
Everything worked fine before I started targeting Android 11, SDK 30.
I have tried to find solutions, I enabled storage permissions: MANAGE_EXTERNAL_STORAGE, QUERY_ALL_PACKAGES, WRITE_EXTERNAL_STORAGE, REQUEST_INSTALL_PACKAGES in manifest, and when the app starts it asks for new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, uri) permission as well.
But even with that my temporary File is not being created. I have tried to find solutions but cannot seem to come up with one. Which direction should I look to create the temp file?
My code to create a temp file:
private File createImageFile() throws IOException {
String timestamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "JPEG_" + timestamp + "_";
File storageDir = activity.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
return File.createTempFile(imageFileName, ".jpg", storageDir);
}