Share video to WhatsApp and other apps using Android Intent (Java)

868 views Asked by At

I want to implement share video to whatsApp and other app feature using Android Intent system. I have been looking for it for last 2 days but I did not get proper solution and some solutions I found on StackOverFlow, they no longer work I guess.

Whenever share Intent opens and I click on whatsApp and choose contact to share then it says file format is not supported

Below is my code:

ContentValues content = new ContentValues(4);
                        content.put(MediaStore.Video.VideoColumns.DATE_ADDED,
                                System.currentTimeMillis() / 1000);
                        content.put(MediaStore.Video.Media.MIME_TYPE, "video/mp4");
                        content.put(MediaStore.Video.Media.DATA, "/storage/emulated/0/WhatsApp/Media/WhatsApp Video/VID-20210822-WA0002.mp4");
                        ContentResolver resolver = getBaseContext().getContentResolver();
                        Uri uri = resolver.insert(MediaStore.Video.Media.EXTERNAL_CONTENT_URI, content);

                        Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
                        sharingIntent.setType("video/*");
                        sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"Title");
                        sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM,uri);
                        startActivity(Intent.createChooser(sharingIntent,"share:"));
0

There are 0 answers