I am using Jsoup to parse the a website, formatting it with Html.fromHtml()
and displaying the formatted text in a textview.
Also, I'm using LinkMoveMentmethod.getInstance
to make the links in the textview clickable.
When the links are clicked they fired up a chooser to choose browsers.
Please, how can I override this default behaviour.
For example, I would want to pass the clicked url to my own activity and use Jsoup to parse it also.
CODE
TextView pageContent;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_page_details);
getWindow().getDecorView().setBackgroundColor(Color.WHITE);
pageContent = (TextView) findViewById(R.id.dpage_content);
}
....
private void parseHtml(String response) {
Log.d(TAG, "parsinghtml");
Document document = Jsoup.parse(response);
page_content = document.select("div.page-content").first().html();
Spanned spanned = Html.fromHtml(page_content, new UILImageGetter(pageContent, this), null );
}
You need to create your custom class which extends LinkMovementMethod.
To use this, change
LinkMovementMethod.getInstance
toLinkClickHandler.getInstance