Open url in default webbrowser

Is there any crossplatform way to open twitter or facebook page from game ?

This works for desktop, I haven’t tested it on mobile:

private void LaunchSite(string url)
{
	try
	{
		System.Diagnostics.ProcessStartInfo webPage = new System.Diagnostics.ProcessStartInfo(url);
		System.Diagnostics.Process.Start(webPage);
	}
	catch { }
}

Also to call it do:

LaunchSite ("https://www.youtube.com/");
1 Like

Thanks, but I need mobile version (wp8/iOS/Android). System.Diagnostics namespace in wp8 application doesn’t contain Process or ProcessStartInfo.

I’m also curious as to whether there’s any way to do this. I found a way for IOS but have had trouble implementing for android. A cross-platform (monogame) solution would certainly be better.

Shorter version that works too:

System.Diagnostics.Process.Start("https://www.youtube.com/");

Thanks for the fast response. Code compiles, but when I push my button that implements the link I get the error: System.ComponentModel.Win32Exception (Cannot find the specified file)

Just for reference in case anyone else is having the same troubles, here’s the code I have right now that is working (where target is a string that is the desired url):

			#if __IOS__
			                UIApplication.SharedApplication.OpenUrl(new Foundation.NSUrl(target));
			#endif

			#if !__IOS__
			                var intent = new Intent(Intent.ActionView, Android.Net.Uri.Parse(target));
			                intent.AddFlags(ActivityFlags.NewTask);
			                Application.Context.StartActivity(intent);
			#endif

Obviously would be cleaner if I could get the monogame implementation to work, but anyway this is getting the job done for me now.