سؤال

i am opening a website using linkify feature of android and getting %20 in my url when opening from my device so what should i do?

here is what i am doing

license=(TextView)findViewById(R.id.find_us_tv3);

    license.setTextSize(18);
    Pattern pattern=Pattern.compile("p"+"[page stackoverflow]+stackoverflow");

    license.setText(" Open the demo page stackoverflow.");
    license.setLinksClickable(true);
    Linkify.addLinks(license, pattern, "http://stackoverflow.com/questions/ask"); 
هل كانت مفيدة؟

المحلول

The "http:/" in your code of
"Linkify.addLinks(license, pattern, "http:/https://stackoverflow.com/questions/ask")"
twice doesn't help.

Just use:

Pattern pattern = Pattern.compile("www.stackoverflow.com/questions/ask");
Linkify.addLinks(license, pattern, "http://");  

Where the text that you mention in pattern should be a part of the text you set in your TextView

Refer: linkify blog link

نصائح أخرى

Try this:

TextView tvWeblink = ((TextView) findViewById(R.id.textView));
        tvWeblink.setTypeface(LandingScreen.font);

        tvWeblink.setClickable(true);
        tvWeblink.setMovementMethod(LinkMovementMethod.getInstance());
        String text = "By pressing this It will open stack overflow page <a href=\"http://stackoverflow.com/questions/ask/\"> ask a question. </a>.";
        tvWeblink.setText(Html.fromHtml(text));
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top