I am trying to encode a URL using UTF-8 and then launch the browser.Below is my code
if(URLUtil.isValidUrl(url)){
//if(Patterns.WEB_URL.matcher(url).matches()) {
url = URLEncoder.encode(url,"UTF-8");
Intent launchUrl = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
System.out.println("encoded new url is "+url);
System.out.println(" launurl is "+launchUrl);
mContext.startActivity(launchUrl);
}
I am getting an exception Activity Not Found.When i remove/comment the encoding line it works fine for me.Pattern matching also not working.
Please help below is the ouput
encoded new url is http%3A%2F%2Fwww.google.com%2F%23output%3Dsearch%26amp%3Bq%3Dnexus
launurl is Intent { act=android.intent.action.VIEW dat=http://www.google.com/#output=search&q=nexus
Input URL is http://www.google.com/#output=search&q=nexus