Issue
Intent sendIntent = new Intent("android.intent.action.MAIN");
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.setType("text/plain");
sendIntent.putExtra(Intent.EXTRA_TEXT, videoLink);
sendIntent.setPackage("com.whatsapp");
startActivity(sendIntent);
I can send the link containing the video to someone on WhatsApp, however, I want to show the image of the video to the user on WhatsApp.
Is there a way to do this in java or kotlin
as in the picture
Solution
I am not sure what you're trying to do exactly but there are two options I can think of.
Firstly, if you're looking for something like what you have in the screenshot then no coding is required.
- This is usually handled by Facebook when their bot scrapes the meta tags from the page that is shared.
- If you wanted to accelerate this process you can manually put the link that you want to share in Facebook's Sharing Debugger and scrape it manually so that Facebook takes note of it.
- Once that is done you can share the link and it should display video information including the image, title & description.
However, if you want to share only the video image/thumbnail you can do that as follows:
- grab the video ID from the URL using REGEX or by taking a substring of the URL that holds the ID.
- Plug that ID in one of the following URLs to get a link to an image that you can share instead of the video.
https://i3.ytimg.com/vi/<insert-youtube-video-id-here>/default.jpg
https://i3.ytimg.com/vi/<insert-youtube-video-id-here>/mqdefault.jpg
https://i3.ytimg.com/vi/<insert-youtube-video-id-here>/sddefault.jpg
https://i3.ytimg.com/vi/<insert-youtube-video-id-here>/hqdefault.jpg
https://i3.ytimg.com/vi/<insert-youtube-video-id-here>/maxresdefault.jpg
Thanks to @asaph for his details answer on getting Youtube thumbnail here
Answered By - Abdelalim Hassouna
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.