I\'m trying to add multiple links in a textview similar to what Google & Flipboard has done below with their Terms and conditions AND Privacy Po
Here's my solution:
First we need to have clickable links in our TextView:
Here's my TextView in the xml layout, do not add any links handling parameters.
In strings file, I added the resource text with html tags
By signing up you agree to our Terms of Service and Privacy Policy.
In onCreateView set LinkMovementMethod to the TextView
TextView privacyTextView = (TextView) root.findViewById(R.id.sign_up_privacy);
privacyTextView.setMovementMethod(LinkMovementMethod.getInstance());
Now the TextView links are clickable.
Second, We need to Handle these clicks:
In my Manifest file, I added intent-filter for "terms" and "privacy" and Single Instance Launch Mode
In MyActivity, override onNewIntent to catch privacy and terms intents
@Override
protected void onNewIntent(Intent intent)
{
if (intent.getScheme().equalsIgnoreCase(getString("terms")))
{
//handle terms clicked
}
else if (intent.getScheme().equalsIgnoreCase(getString("privacy")))
{
//handle privacy clicked
}
else
{
super.onNewIntent(intent);
}
}