【问题标题】:Preview a URL in android, the way facebook does before you post a link (Link Preview) [closed]在 android 中预览 URL,就像 facebook 在发布链接之前所做的那样(链接预览)[关闭]
【发布时间】:2016-07-18 21:07:55
【问题描述】:

我有一个 EditText 来输入网络链接。我想预览输入的 URL,类似于 Facebook 中的功能,我们在其中发布链接并会看到页面的图像,标题在顶部,URL 在底部。

如何在 Android 中进行开发?

【问题讨论】:

  • 你做了什么,没做什么?
  • 这不应该被关闭。值得提出一个体面的问题。
  • 我刚刚尝试通过URLEmbeddedView 在我的应用程序中实现预览 URL 功能,它运行良好。在此之前,我尝试实现几乎所有的解决方案,但都失败了,因为大多数都已经过时并且不支持最新的 Android API 级别。如果有人遇到问题,请告诉我

标签: android url


【解决方案1】:

在用户在editext中输入链接后使用JSOUP来解析你的链接OG元标签(这是FB看的)刮掉元标签:

这是您想要从最近的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"/>

【讨论】:

猜你喜欢
  • 2014-07-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-08-31
  • 2011-11-03
  • 1970-01-01
  • 2013-04-12
相关资源
最近更新 更多