0

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:"));
Abhay
  • 101
  • 2
  • 7
  • First, use a concrete MIME type with `ACTION_SEND`. Second, you do not have rights to access that content on Android 11+. – CommonsWare Aug 26 '21 at 16:43
  • Hey @CommonsWare, can you tell me what is mean by concrete MIME type? – Abhay Aug 27 '21 at 04:59
  • `video/*` is a wildcard MIME type. Do not use that when you are the *supplier* of content. Use a concrete MIME type, like `video/mp4`. – CommonsWare Aug 27 '21 at 11:08
  • @CommonsWare I did changes as you said and I tested app on Android 8, 10. Still it says "This file format is not supported" Now I really do not have any idea what to do, I have been searching for it from last 3 days. – Abhay Aug 27 '21 at 13:52

0 Answers0