我正在尝试使用文档中的代码示例将 ADF 从项目 tango 导出到 sdcard,但它对我来说失败了。我能够使用正确的导出路径成功弹出导出对话框。但是,当我点击导出按钮时,我的日志失败了
12-16 00:48:12.203 192-603/? E/tango_service_library_context﹕ bool RuntimeExportAreaDescription(const string&, const string&, const string&): Internal error occured opening file: /storage/emulated/0/c5617dae-01b0-4825-8ee1-777c17693414
12-16 00:48:12.209 8246-8246/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: com.projecttango.tango, PID: 8246
com.google.atap.tangoservice.TangoInvalidException
at com.google.atap.tango.TangoInternal.throwTangoExceptionIfNeeded(TangoInternal.java:118)
at com.google.atap.tango.TangoInternal.exportAreaDescriptionFile(TangoInternal.java:104)
at com.google.atap.tango.RequestImportExportActivity.onExportAccepted(RequestImportExportActivity.java:83)
at com.google.atap.tango.RequestImportExportDialog$1.onClick(RequestImportExportDialog.java:108)
at android.view.View.performClick(View.java:4438)
at android.view.View$PerformClick.run(View.java:18422)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5030)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
我的应用程序具有对外部存储的读/写访问权限,我通过编写具有相同路径的文件进行了验证,该文件运行良好。
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
这是我的导出代码(取自探戈文档):
adfToExport = GetAdfs().get(0);
String externalStorageDirectory = Environment.getExternalStorageDirectory().toString();
/* this was just a test to verify the app can write to the path
try {
String path = externalStorageDirectory + "/c5617dae-01b0-4825-8ee1-777c17693414";
File file = new File(path);
FileOutputStream fOut = new FileOutputStream(file);
OutputStreamWriter myOutWriter = new OutputStreamWriter(fOut);
myOutWriter.append("testing 1 2 3");
myOutWriter.close();
fOut.close();
} catch (Exception ex) {
Log.e(LOG_TAG, "failed to write file: " + path, ex);
}
*/
Intent exportIntent = new Intent();
exportIntent.setClassName(INTENT_CLASSPACKAGE, INTENT_IMPORTEXPORT_CLASSNAME);
exportIntent.putExtra(EXTRA_KEY_SOURCEUUID, adfToExport);
exportIntent.putExtra(EXTRA_KEY_DESTINATIONFILE, externalStorageDirectory);
startActivityForResult(exportIntent, Tango.TANGO_INTENT_ACTIVITYCODE);