t3nshi commented on issue #328:
URL:
https://github.com/apache/cordova-plugin-inappbrowser/issues/328#issuecomment-678374903
Actually I was still having the same issue with image not loading on Android
10 and in some devices not even opening the camera, the problem was that the
code for the temporary file creation in here:
``` java
private File createImageFile() throws IOException{
@SuppressLint("SimpleDateFormat") String timeStamp = new
SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "img_"+timeStamp+"_";
File storageDir =
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
return File.createTempFile(imageFileName,".jpg",storageDir);
}
```
I changed the Environment.getExternalStoragePublicDirectory as it is
deprecated on API 29 onwards, using this:
``` java
private File createImageFile() throws IOException{
@SuppressLint("SimpleDateFormat") String timeStamp = new
SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "img_"+timeStamp+"_";
if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
// let's use the new api for accessing external storage on 29
onwards
File storageDir =
this.cordova.getActivity().getExternalFilesDir(Environment.DIRECTORY_PICTURES);
File file = new File(storageDir, imageFileName + ".jpg");
return file;
} else {
// was working well on older droids so let's leave it as is.
File storageDir =
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File file =
File.createTempFile(imageFileName,".jpg",storageDir);
return file;
}
}
```
Thought I just left this here in case someone else is having the same
struggle.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]