-2

enter image description here

What this is called?

How to implement?

Is there any Lib/API?

Dhruv Patel
  • 1,529
  • 1
  • 18
  • 27

1 Answers1

1

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

Here is Another Library.

Tomin B Azhakathu
  • 2,656
  • 1
  • 19
  • 28