Reputation: 3748
I use Xamarin and debug on an Android device.
How to redirect an url in Xamarin.Forms?
I'm trying this in default page load.
Upvotes: 2
Views: 4504
Reputation: 1704
You can use Device.OpenUri
to open the URL in the mobile browser:
Device.OpenUri(new Uri("http://xamarin.com"));
Here is a sample implementation:
using System;
using Xamarin.Forms;
namespace Example
{
class MyPage : ContentPage
{
public MyPage()
{
Button button = new Button
{
Text = "Open URL",
Font = Font.SystemFontOfSize(NamedSize.Large),
BorderWidth = 1,
HorizontalOptions = LayoutOptions.Center,
VerticalOptions = LayoutOptions.CenterAndExpand
};
button.Clicked += OnButtonClicked;
this.Content = new StackLayout
{
Children = {
button
}
};
}
void OnButtonClicked(object sender, EventArgs e)
{
Device.OpenUri(new Uri("http://xamarin.com"));
}
}
}
Upvotes: 3