2017-05-29 85 views
1

我试图在CSV表格中打开一个CSV文件,但我不能。Android意图在电子表格中打开CSV

这就是一切正常,我可以将我的CSV保存到Google云端硬盘,然后从云端硬盘中打开它,但我想直接打开Goog​​le表格。

这可能吗?

Intent shareIntent = new Intent(); 

     Uri contentUri = FileProvider.getUriForFile(activity.getApplication(), 
       activity.getApplication().getPackageName(), file); 
     activity.getApplication().grantUriPermission(activity.getApplication().getPackageName(), 
       contentUri, Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); 
     shareIntent.setData(contentUri); 
     shareIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); 
     shareIntent.setAction(Intent.ACTION_SEND); 
     shareIntent.putExtra(Intent.EXTRA_STREAM, contentUri); 
     shareIntent.setType("text/csv"); 

     activity.startActivity(Intent.createChooser(shareIntent, "Abrir CSV")); 

I got only this options in intent chooser. I want Sheets here.

提供者:

<provider 
     android:name="android.support.v4.content.FileProvider" 
     android:authorities="${applicationId}" 
     android:exported="false" 
     android:grantUriPermissions="true"> 
     <meta-data 
      android:name="android.support.FILE_PROVIDER_PATHS" 
      android:resource="@xml/file_paths" /> 

XML/file_paths:

<paths xmlns:android="http://schemas.android.com/apk/res/android"> 
    <external-cache-path name="external_files" path="."/> 
</paths> 

在此先感谢大家!

+0

庵,获得与谷歌工作,安排在谷歌表团队合作,并添加功能,谷歌表,使其能够打开CSV文件,我猜。 – CommonsWare

+0

可以使用工作表打开CSV,我可以通过点击我的手指在我的谷歌驱动器上的csv文件中手动完成:D – jonaspauleta

+0

这并不意味着Google向第三方开发人员展示了该功能。 – CommonsWare

回答

0

将MIME类型设置为text/*并且应显示床单。

还要注意的是调用setTypesetData将实际的数据集null

相关问题