Open a webpage without using webview

I would like to open a webpage using a web browser on the device. I'm using WebView right now, but I want to allow the user to choose between Chrome, Safari or any other web browser located on this device. Is there any way to do this?

+4
source share
4 answers
var url = "http://www.google.com";
Device.OpenUri(new Uri(url));

And for this, the default browser is used.

Source: https://forums.xamarin.com/discussion/comment/94202#Comment_94202

Docs API: Xamarin.Forms.Device.OpenUri

+14
source

I am using this code:

var uri = Android.Net.Uri.Parse ("http://www.google.com");
var intent = new Intent (Intent.ActionView, uri); 
StartActivity (intent);

And the compact version:

StartActivity (new Intent (Intent.ActionView, Android.Net.Uri.Parse ("http://www.google.com"))); 
+2
source

,

WebView web_view;

    protected override void OnCreate (Bundle bundle)
    {
        base.OnCreate (bundle);

        SetContentView (Resource.Layout.Social);


        web_view = FindViewById<WebView> (Resource.Id.webView);
        web_view.Settings.JavaScriptEnabled = true;
        web_view.SetWebViewClient (new HelloWebViewClient ());
        web_view.Settings.LoadWithOverviewMode = true;
        web_view.Settings.UseWideViewPort = true;
        web_view.LoadUrl ("http://www.facebook.com");


    }

    public class HelloWebViewClient : WebViewClient
    {
        public override bool ShouldOverrideUrlLoading (WebView view, string url)
        {
            view.LoadUrl (url);
            return true;
        }
    }
0

, - , -, .

.

-2
source

Source: https://habr.com/ru/post/1568638/


All Articles