我有一个EditText来输入网络链接。我想预览输入的URL,类似于Facebook中的功能,我们在其中发布链接并将看到页面的图像,标题位于顶部,URL位于底部。
如何在Android中开发此功能?
答案 0 :(得分:6)
用户在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"/>