9

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?

mysticfyst
  • 347
  • 4
  • 9
Saiful
  • 279
  • 4
  • 10
  • What is it that you've done and didn't work? – slybloty Mar 15 '13 at 17:55
  • 3
    This shouldn't be closed. Worth a decent question. – Srujan Barai Oct 22 '16 at 08:24
  • I just tried and implement the Preview a URL feature into my app through [URLEmbeddedView](https://github.com/nguyencse/URLEmbeddedView) and it was working perfectly fine. Before that, I tried to implement almost all solutions but failed because mostly are outdated and do not support the latest Android API levels. Let me know if anyone is facing an issue – Muhammad Afzal Apr 22 '22 at 01:59

1 Answers1

13

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"/>
petey
  • 16,914
  • 6
  • 65
  • 97
  • Those who want to implement through a Github library then they can checkout this library https://github.com/nguyencse/URLEmbeddedView – Muhammad Afzal Apr 22 '22 at 02:00