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
Chrome custom tabs are now available:
The first step is adding the Custom Tabs Support Library to your build.gradle file:
And then, to open a chrome custom tab:
For more info: https://developer.chrome.com/multidevice/android/customtabs
android.webkit.URLUtil
has the methodguessUrl(String)
working perfectly fine (even withfile://
ordata://
) sinceApi level 1
(Android 1.0). Use as:In the Activity call:
Check the complete
guessUrl
code for more info.If you want to do this with XML not programmatically you can use on your TextView:
You can also go this way
In xml :
In java code :
In Manifest dont forget to add internet permission...
Simple, website view via intent,
use this simple code toview your website in android app.
Add internet permission in manifest file,
Okay,I checked every answer but what app has deeplinking with same URL that user want to use?
Today I got this case and answer is
browserIntent.setPackage("browser_package_name");
e.g. :
Thank you!