I have a custom dialog that has a Textview inside. I want to add a hyperlink to the text. I tried using setMovementMethod(LinkMovementMethod.getInstance()) but it is still not working. However it works when I apply it to a textview that is not in my custom dialog.
Here is my dialog.
final Dialog dialog = new Dialog(this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setCancelable(true);
    dialog.setContentView(R.layout.license_dialog_layout);
    TextView text = dialog.findViewById(R.id.text_dialog);
    String str = "Link";
    text.setText(context.getResources().getString(R.string.my_link, str));
    dialog.show();
    text.setMovementMethod(LinkMovementMethod.getInstance());
My string resource:
<string name="my_link"><a href="https://www.google.com/">%1$s</a></string>
Xml:
<TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:autoLink="web"
    android:id="@+id/text_dialog" />
 
     
    