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
Try this..Worked for me!
xml code :-
--------- OR------------------
other option In Load Url in Same Application using Webview
Just like the solutions other have written (that work fine), I would like to answer the same thing, but with a tip that I think most would prefer to use.
In case you wish the app you start to open in a new task, indepandant of your own, instead of staying on the same stack, you can use this code:
The response of MarkB is right. In my case I'm using Xamarin, and the code to use with C# and Xamarin is:
This information is taked from: https://developer.xamarin.com/recipes/android/fundamentals/intent/open_a_webpage_in_the_browser_application/