如何通过意图发送csv文件

问题描述 投票:0回答:1

这是开始共享意图的功能当Shairing共享框打开时,我可以选择所有选项,例如whatsapp,gmail,同时选择这些选项,文件将不会被附加

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"));



    }

共享框正在打开,请帮助我解决此问题

错误消息

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.
android android-intent
1个回答
0
投票

将以下代码添加到清单的意图过滤器中。

 <data android:mimeType="text/comma_separated_values/csv" />

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

© www.soinside.com 2019 - 2024. All rights reserved.