I’m trying to open a url in a web browser using the following code,
does not work
Bundle ex=in.getExtras();
link=ex.getString("link");
public void onClick(View arg0) {
Intent t=new Intent(Intent.ACTION_VIEW);
Uri u=Uri.parse(link);
t.setData(u);
startActivity(t);
}
but i’m havinng a weird problem.When i use the exact url instead of string “link” everything works as it should, but when i go with the String link that i created i get the “no activity found to handle intent” exception.But i’m sure the link contains the right url, the same that i used before.
this works
public void onClick(View arg0) {
Intent t=new Intent(Intent.ACTION_VIEW);
Uri u=Uri.parse("http://google.com");
t.setData(u);
startActivity(t);
}
i’m sure that in the first case link contains the url (http://google.com), besides i printed on a textview to check!
Well, the problem was caused by a whitespace at the of ‘link’.I used link.trim() and it worked correctly. Thank you guys for your help.