我收到错误消息:“上传失败。无法安排1个文件进行上传”。我正在尝试创建一个简单的文件浏览器。当用户点击listView上的非文件夹项时,会出现一个Google云端硬盘上传对话框,但是当我点击Google云端硬盘对话框中的SAVE按钮时出现错误。下面显示了我的编码。请告诉我我做错了哪些部分。谢谢你。
protected void onListItemClick(ListView l, View v, int position, long id) {
// TODO Auto-generated method stub
super.onListItemClick(l, v, position, id);
Option o = adapter.getItem(position);
if(o.getData().equalsIgnoreCase("folder")||o.getData().equalsIgnoreCase("parent directory")){
currentDir = new File(o.getPath());
fill(currentDir);
}
else
{
onFileClick(o);
}
}
private void onFileClick(Option o)
{
Toast.makeText(this, "File Clicked: "+o.getName(), Toast.LENGTH_SHORT).show();
String uri = o.getPath();
Uri uploadUri = Uri.parse(uri);
Toast.makeText(this, "This file is located at: "+uploadUri, Toast.LENGTH_SHORT).show();
if (uri.contains(".txt")) {
Intent uploadIntent = ShareCompat.IntentBuilder.from(this)
.setText("Share Document")
.setType("application/txt")
.setStream(uploadUri)
.getIntent()
.setPackage("com.google.android.apps.docs");
startActivity(uploadIntent);
}else{
//TODO: what to do when it is other file format
}
}
在onFileClick()中:
改变
String uri = o.getPath();
到
String uri = "file://" + o.getPath();
然后你去了!:)
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句