How to open an URL from code in the built-in web browser rather than within my application?
I tried this:
try {
Intent myIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(download_link));
startActivity(myIntent);
} catch (ActivityNotFoundException e) {
Toast.makeText(this, "No application can handle this request."
+ " Please install a webbrowser", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
but I got an Exception:
No activity found to handle Intent{action=android.intent.action.VIEW data =www.google.com
Check whether your url is correct. For me there was an unwanted space before url.
If you want to show user a dialogue with all browser list, so he can choose preferred, here is sample code:
//OnClick Listener
//Your Util Method
Webview can be used to load Url in your applicaion. URL can be provided from user in text view or you can hardcode it.
Also don't forget internet permissions in AndroidManifest.