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();
}
I tried to open a URL.
No activity found to handle Intent{action=android.intent.action.VIEW data =www.google.com
There was an error.
android url android-intent android-browser
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
startActivity(browserIntent);
Do it like this. When url is used as a variable, prepare for when http:// is not attached
if (!url.startsWith("http://") && !url.startsWith("https://"))
url = "http://" + url;
It's good to do it like this.
© 2024 OneMinuteCode. All rights reserved.