But share the qq is ok, and use system share own file manager to WeChat sure
The code is as follows:
public static void shareFile (Context Context, String fileName) {
The File File=new File (fileName);
if (null !=the file & amp; & File. The exists ()) {
Intent share=new Intent (Intent. ACTION_SEND);
//above android7 FileProvider
If (Build) VERSION) SDK_INT & gt;=Build. VERSION_CODES. N) {
Uri contentUri=FileProvider. GetUriForFile (context, BuildConfig APPLICATION_ID + ". FileProvider ", the file).
Share. PutExtra (Intent. EXTRA_STREAM contentUri);
} else {
Share. PutExtra (Intent. EXTRA_STREAM, Uri fromFile (file));
}
Share. SetType (" application/octet - stream ");
Share. SetFlags (Intent. FLAG_ACTIVITY_NEW_TASK);
Share. AddFlags (Intent. FLAG_GRANT_READ_URI_PERMISSION);
Context. StartActivity (Intent. CreateChooser (share, "file sharing"));
} else {
Toast. MakeText (context, "Shared file does not exist," Toast. LENGTH_SHORT), show ();
}
}
CodePudding user response:
If you put the share. SetType (" application/octet - stream "); to share. SetType (" application/db "); in this way, it would be?CodePudding user response: