I am facing a strange problem after putting all the effort I am still unable to solve it.
The problem is:
I have a textview which is loading data directly from Twitter
. Tweets may contains many links and it is getting displayed in the textview, but on clicking links, they are opening in android default browser
. What I want to do is when user click any of the link how will I detect which link has been clicked
and open my webview instead of default browser
.
Here what I have reached until now:
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello www.google.com Thank You"
android:autoLink="web"
android:id="@+id/activity_main_textview"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Java
TextView textView = (TextView) findViewById(R.id.activity_main_textview);
textView.setText("www.google.com is first link, www.facebook.com is second link, www.instagram.com is third link");
textView.setMovementMethod(LinkMovementMethod.getInstance());