I am trying to share video from uri using file provider, but I can't understand how can I pass the uri to share video.
can anyone help me out of this problem
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.xyz.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_provider_paths" />
</provider>
path.xml
<cache-path name="shared_videos" path="videos/"/>
here i am passing the uri
final String path = fileslist.get(position).getPath();
String destPath = Environment.getExternalStorageDirectory().getAbsolutePath()+Constant.SAVE_FOLDER_NAME;
Intent intent = new Intent(context,Video.class);
intent.putExtra("Dest_path_video", destPath);
intent.putExtra("File_video", path);
intent.putExtra("FileName_video", modalClass.getFileName());
intent.putExtra("Uri_video", modalClass.getUri().toString());
context.startActivity(intent);
here is uri
String video_uri = fileslist.get(position).getUri().toString();
here how I am trying to share video
Uri uri = null;
try {
File videoPath = new File(context.getCacheDir(), "videos");
imagePath.mkdirs();
File file = new File(videoPath , "shared_videos.mp4");
uri = getUriForFile(context, "com.xyz.fileprovider", file);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_STREAM, uri);
intent.setType("video/*");
context.startActivity(Intent.createChooser(intent, "Share Via"));
} catch (Exception e) {
Log.d("test",""+e.getMessage());
}
make sure you have
in AndroidManifest.xml.
I don't sure about getUriForFile method in your code, it should look like this:
And can u provide an example URI of your video???