从代号一访问 Android 路径?
Access Android Paths from Codename one?
我正在尝试制作一段代码,以便我可以打开从本机代码返回的文件,但是如果我使用
FileSystemStorage.getInstance().exists(file)
它总是 returns false 即使我只是从本机代码返回路径
我的代码返回了这样的路径:
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath() +"/"+param+System.currentTimeMillis()+".png";
如果你检查一下你可以在图库中找到它,但是当返回代号一时它看不到文件
任何建议
---------------- 更新:
我是这样调用本机的,但它似乎没有等待调用完成
final StatusClass imagePath = new StatusClass();
Display.getInstance().invokeAndBlock(new Runnable() {
public void run() {
Log.p("hello native");
imagePath.setStatusMsg(AccessNativeCamera.capturePhoto("Test"));
Log.p("goodbye native");
Log.p("imagePath "+imagePath);
}
});
if(FileSystemStorage.getInstance().exists("file://" + imagePath.getStatusMsg())){
Dialog.show("Check ","File exists", null, null);
}
此致,
这应该有效:
FileSystemStorage.getInstance().exists("file://" + file)
代号一中的路径始终是绝对路径,应使用 URL 表示法。
我正在尝试制作一段代码,以便我可以打开从本机代码返回的文件,但是如果我使用
FileSystemStorage.getInstance().exists(file)
它总是 returns false 即使我只是从本机代码返回路径
我的代码返回了这样的路径:
String path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath() +"/"+param+System.currentTimeMillis()+".png";
如果你检查一下你可以在图库中找到它,但是当返回代号一时它看不到文件
任何建议
---------------- 更新:
我是这样调用本机的,但它似乎没有等待调用完成
final StatusClass imagePath = new StatusClass();
Display.getInstance().invokeAndBlock(new Runnable() {
public void run() {
Log.p("hello native");
imagePath.setStatusMsg(AccessNativeCamera.capturePhoto("Test"));
Log.p("goodbye native");
Log.p("imagePath "+imagePath);
}
});
if(FileSystemStorage.getInstance().exists("file://" + imagePath.getStatusMsg())){
Dialog.show("Check ","File exists", null, null);
}
此致,
这应该有效:
FileSystemStorage.getInstance().exists("file://" + file)
代号一中的路径始终是绝对路径,应使用 URL 表示法。