error: cannot find symbol: method createUriForFile(Context,File)
error: cannot find symbol: method createUriForFile(Context,File)
我试过了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 有需要的代码。我想直接问这个问题,但没有声誉发表评论,所以我必须创建这个 thead。
另外,我是 java 的新手,所以如果我的问题听起来很愚蠢,我很抱歉。
我已经解决了这个问题。不确定这是最好的方法,但它可以在我的设备上使用 android 11 和 cordova 9.0。
我在 NoodleOfDeath 的解决方案中更改了 onShowFileChooser 方法主体内的 try-catch 块。
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;
}
我试过了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 有需要的代码。我想直接问这个问题,但没有声誉发表评论,所以我必须创建这个 thead。
另外,我是 java 的新手,所以如果我的问题听起来很愚蠢,我很抱歉。
我已经解决了这个问题。不确定这是最好的方法,但它可以在我的设备上使用 android 11 和 cordova 9.0。 我在 NoodleOfDeath 的解决方案中更改了 onShowFileChooser 方法主体内的 try-catch 块。
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;
}