Md. Saiful Islam Md. Saiful Islam - 5 months ago 72
Android Question

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

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?


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=""/>
<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=""/>