In my app, I am sharing my videos to another app, it works fine on older version devices but not working in higher versions more than 5.0 (marshmallow). I am doing this in a fragment.
Please help. Thanks in advance.
This is my code
holder.thumbnail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent sendIntent = new Intent();
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setType("video/*");
sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(currentFile));
activity.startActivity(Intent.createChooser(sendIntent, "Share to"));
}
});
Try using ShareCompat.IntentBuilder:
Intent shareIntent = ShareCompat.IntentBuilder.from(YourActivity.this)
.setChooserTitle("Share to")
.setType("video/*")
.setStream(Uri.fromFile(currentFile))
.getIntent();
if (shareIntent.resolveActivity(getPackageManager()) != null){
startActivity(shareIntent);
}
Refer to this documentation : ShareCompat.IntentBuilder
Thanks guys for the support .
I have solved the issuse using the concept of Sharing files using FileProvider
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.