将Excelfile upload到Dropbox或Google Drive?

我目前正在开发一个应用程序,从Android的SQLite数据库创build一个Excel文件(与Apache POI)。 一切运作良好,除了我不能发送文件到另一个应用程序。 我实现了一个文件提供程序,所以我其他应用程序可以有我的文件的权限:

AndroidManifest.xml中:

<provider android:name="android.support.v4.content.FileProvider" android:authorities="com.example.ria.masterdetailnoten" android:exported="false" android:grantUriPermissions="true"> <meta-data android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/file_paths"></meta-data> </provider> 

file_paths.xml:

 <?xml version="1.0" encoding="utf-8"?> <paths xmlns:android="http://schemas.android.com/apk/res/android"> <files-path name="backup" path="backup/"/> </paths> 

ExcelFile.java:

 Uri uriFile = FileProvider.getUriForFile(ct, "com.example.ria.masterdetailnoten", backupFile); Intent intent = new Intent(Intent.ACTION_SEND); intent.setDataAndType(uriFile, "application/vnd.ms-excel"); intent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.createChooser(intent, "Choose"); ct.startActivity(intent); 

我知道我的文件正在创build,我可以用Apache POI重新读取它。 所以唯一不起作用的是把意图发送到另一个应用程序。


例如,如果我在意向select器中selectGoogle Drive,则会出现以下错误:“上传失败:请求中没有数据”。

如果我打开它的邮箱应用程序出现以下错误:“邮箱无法读取选定的文件”

我希望你能帮助我,我感谢你的帮助!

你有没有尝试过使用: putExtra(Intent.EXTRA_STREAM, uriFile)而不是: setData(AndType)