What this is called?
How to implement?
Is there any Lib/API?
This feature is called Rich Link.
Rich Links Can Be easily implemented using Android Link Preview Library
It is attained by adding the following to the gradle
add following repository
repositories {
jcenter()
maven { url 'https://github.com/leonardocardoso/mvn-repo/raw/master/maven-deploy' }
}
Add the following gradle file
compile 'org.jsoup:jsoup:1.8.3' // required
compile 'com.leocardz:link-preview:2.0.0@aar'
If you are using Proguard Rules add the following rule
-keeppackagenames org.jsoup.nodes
Implementation
Intialisation
import com.leocardz.link.preview.library.TextCrawler;
// ...
// Create an instance of the TextCrawler to parse your url into a preview.
TextCrawler textCrawler = new TextCrawler();
// ..
// Create the callbacks to handle pre and post exicution of the preview generation.
LinkPreviewCallback linkPreviewCallback = new LinkPreviewCallback() {
@Override
public void onPre() {
// Any work that needs to be done before generating the preview. Usually inflate
// your custom preview layout here.
}
@Override
public void onPos(SourceContent sourceContent, boolean b) {
// Populate your preview layout with the results of sourceContent.
}
};
Generate Preview
textCrawler.makePreview( linkPreviewCallback, url);
Try this please