Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preview a URL in android, the way facebook does before you post a link (Link Preview) [closed]

Tags:

android

url

I have an EditText to input a web link. I want to preview the inputted URL, similar to the function in Facebook, where we post a link and will see an image of the page, with the title on top and URL at the bottom.

How can I develop this in Android?

like image 770
Saiful Avatar asked Mar 15 '13 17:03

Saiful


People also ask

How does Facebook link preview work?

Facebook link preview is basically the way your link will appear on Facebook when published. A line of text vs. title, description and image. There were times when anyone could edit link previews on Facebook which Facebook eventually banned in 2017, in hopes to stop people from using this feature with bad intentions.

Does previewing a link open it?

An app or social media platform downloads the link content and generates the preview. The receiving app then shows the preview. It doesn't need to open the link, so potentially malicious content hosted on the linked website doesn't reach the user right away.

What happens when you preview a link?

Link previews offer a peek at content such as web pages or documents in many messaging apps. The feature allows users to see a short summary and preview image inline with the rest of the conversation without having to tap on the link.

How do I post a link on Facebook without preview?

You can find the cross icon at the top-right corner of the post preview. Click the cross icon, and the link metadata preview will be removed. The post preview will update to show what the Facebook post will look like when published.


1 Answers

Use JSOUP after the user enters a link in the editext to parse out your links OG meta tags (this is what FB looks at) scrape out the meta tags:

Here is an example of the meta info you want from a recent nytimes article

<meta property="og:url" content="http://www.nytimes.com/2013/03/16/world/europe/pope-francis-praises-benedict-urges-cardinals-to-spread-gospel.html"/>
<meta property="og:type" content="article"/>
<meta property="og:title" content="Vatican Rejects Argentine Accusations Against Pope Francis"/>
<meta property="og:description" content="The Vatican on Friday formally defended Pope Francis’ role in Argentina’s so-called “Dirty War,” amid accusations that he failed to halt abuses of which he had knowledge.">
<meta property="og:image" content="http://graphics8.nytimes.com/images/2013/03/16/world/16vatican/16vatican-superJumbo.jpg"/>
like image 166
petey Avatar answered Oct 07 '22 01:10

petey