首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何通过intent发送csv文件

如何通过intent发送csv文件
EN

Stack Overflow用户
提问于 2020-02-28 22:54:18
回答 2查看 82关注 0票数 0

这是在共享共享框打开时启动共享意图的功能,我可以选择所有选项,如whatsapp、gmail,同时选择文件未附加的那些选项

代码语言:javascript
复制
private void OpenShare(String filename) {


        Uri uri = Uri.parse(( getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS).getPath()+filename));


        Intent sharingIntent = new Intent();
        sharingIntent.setAction(Intent.ACTION_SEND);
        sharingIntent.setDataAndType(uri, "text/*");
        startActivity(Intent.createChooser(sharingIntent, "share file with"));



    }

共享信箱正在打开,请帮我解决这个问题

错误消息

代码语言:javascript
复制
2020-02-28 20:09:19.821 14722-14903/com.digicita.digiflow E/ActivityThread: Failed to find provider info for cn.teddymobile.free.anteater.den.provider
2020-02-28 20:09:20.719 14722-14821/com.digicita.digiflow E/Parcel: Reading a NULL string not supported here.
2020-02-28 20:09:21.484 14722-14722/com.digicita.digiflow E/Parcel: Reading a NULL string not supported here.
2020-02-28 20:09:24.422 14722-14722/com.digicita.digiflow E/ANR_LOG: >>> msg's executing time is too long
2020-02-28 20:09:24.422 14722-14722/com.digicita.digiflow E/ANR_LOG: Blocked msg = { when=-2s378ms what=100 target=android.app.ActivityThread$H obj=ActivityRecord{40b44d2 token=android.os.BinderProxy@67a38f1 {com.digicita.digiflow/com.digicita.digiflow.MainActivity}} } , cost  = 2328 ms
2020-02-28 20:09:24.422 14722-14722/com.digicita.digiflow E/ANR_LOG: >>>Current msg List is:
2020-02-28 20:09:24.422 14722-14722/com.digicita.digiflow E/ANR_LOG: Current msg <1>  = { when=-2s350ms what=101 target=android.app.ActivityThread$H obj=com.android.internal.os.SomeArgs@43079a3 }
2020-02-28 20:09:24.423 14722-14722/com.digicita.digiflow E/ANR_LOG: Current msg <2>  = { when=-2s325ms what=109 target=android.app.ActivityThread$H arg1=1 obj=android.os.BinderProxy@929e1d }
2020-02-28 20:09:24.423 14722-14722/com.digicita.digiflow E/ANR_LOG: Current msg <3>  = { when=-1s845ms what=103 target=android.app.ActivityThread$H obj=com.android.internal.os.SomeArgs@4c5a4a0 }
2020-02-28 20:09:24.423 14722-14722/com.digicita.digiflow E/ANR_LOG: Current msg <4>  = { when=-1s845ms what=137 target=android.app.ActivityThread$H arg1=1 obj=android.os.BinderProxy@67a38f1 }
2020-02-28 20:09:24.423 14722-14722/com.digicita.digiflow E/ANR_LOG: Current msg <5>  = { when=-1s468ms what=0 target=android.os.Handler callback=androidx.core.content.res.ResourcesCompat$FontCallback$2 }
2020-02-28 20:09:24.424 14722-14722/com.digicita.digiflow E/ANR_LOG: Current msg <6>  = { when=-1s402ms what=0 target=android.os.Handler callback=androidx.core.content.res.ResourcesCompat$FontCallback$2 }
2020-02-28 20:09:24.424 14722-14722/com.digicita.digiflow E/ANR_LOG: Current msg <7>  = { when=-1s162ms what=0 target=android.os.Handler callback=androidx.core.content.res.ResourcesCompat$FontCallback$2 }
2020-02-28 20:09:24.424 14722-14722/com.digicita.digiflow E/ANR_LOG: Current msg <8>  = { when=-1s100ms what=0 target=android.os.Handler callback=androidx.core.content.res.ResourcesCompat$FontCallback$2 }
2020-02-28 20:09:24.424 14722-14722/com.digicita.digiflow E/ANR_LOG: Current msg <9>  = { when=-1s92ms what=0 target=android.os.Handler callback=androidx.core.content.res.ResourcesCompat$FontCallback$2 }
2020-02-28 20:09:24.425 14722-14722/com.digicita.digiflow E/ANR_LOG: Current msg <10>  = { when=-1s84ms what=0 target=android.os.Handler callback=androidx.core.content.res.ResourcesCompat$FontCallback$2 }
2020-02-28 20:09:24.425 14722-14722/com.digicita.digiflow E/ANR_LOG: >>>CURRENT MSG DUMP OVER<<<
2020-02-28 20:09:38.731 14722-14722/com.digicita.digiflow E/Parcel: Reading a NULL string not supported here.
2020-02-28 20:09:47.514 14722-14722/com.digicita.digiflow E/Parcel: Reading a NULL string not supported here.
2020-02-28 20:10:19.139 14722-14722/com.digicita.digiflow E/Parcel: Reading a NULL string not supported here.
2020-02-28 20:14:01.323 14722-14722/com.digicita.digiflow E/Parcel: Reading a NULL string not supported here.
2020-02-28 20:14:24.794 14722-14722/com.digicita.digiflow E/Parcel: Reading a NULL string not supported here.
EN

回答 2

Stack Overflow用户

发布于 2020-03-14 03:30:55

将以下代码添加到清单中的intent-filter。

代码语言:javascript
复制
 <data android:mimeType="text/comma_separated_values/csv" />

并将MIME类型更改为text/plaintext/csvtext/comma-separated-values

票数 0
EN

Stack Overflow用户

发布于 2021-03-22 13:59:50

尝试使用

代码语言:javascript
复制
intent.setType("text/*");

确保您的测试设备上安装了足够的应用程序。("text/csv")是正确的格式,但是您可以尝试使用("text/plain"),它将打开所有已安装的文本编辑器。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60454168

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档