I've tried NoodleOfDeath's solution of Cordova Android clicking input problem, but I faced with a problem: "cannot find symbol"
for createTempFile
and createUriForFile
methods. As far as I understand I should import this methods, but google don't show any examples. Or it should be some library, which has these methods, or only @NoodleOfDeath has required code. I would like to ask this question directly, but have no reputation make comments, so I have to create this thead.
Also I'am newbie in java, so I'm sorry if my question sounds stupid.
CodePudding user response:
I've solved the problem. Not sure that this is the best way, but it works on my device with android 11, and cordova 9.0. I've changed the try-catch block inside the body of onShowFileChoosermethod in NoodleOfDeath's solution.
try {
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
String imageFileName = "img_" timeStamp "_";
File storageDir = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES);
File tempFile = File.createTempFile(imageFileName,".jpg", storageDir);
Log.d(LOG_TAG, "Temporary photo capture file: " tempFile);
tempUri = Uri.fromFile(tempFile);
Log.d(LOG_TAG, "Temporary photo capture URI: " tempUri);
captureIntent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, tempUri);
} catch (IOException e) {
Log.e(LOG_TAG, "Unable to create temporary file for photo capture", e);
captureIntent = null;
}