簡體   English   中英

嘗試使用 xamarin android 和 c# 打開默認瀏覽器

[英]Trying to open the default browser using xamarin android with c#

所以在 c# 中,我使用 System.Diagnostics.Process.Start("https:/.....) 並且效果很好。到目前為止,我移植到 Xamarin Android 的所有內容都可以工作,除了這個。當它在Android 應用程序,什么都沒有...zip...nada。

來自 Xamarin 文檔

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

您可以使用應用中的 url 打開Chrome browser

string urlString = "http://google.com";
Intent intent1 = new Intent(Intent.ActionView, Uri.Parse(urlString));
intent.AddFlags(ActivityFlags.NewTask);
intent.SetPackage("com.android.chrome");
try
{
    context.StartActivity(intent1);
}
catch (ActivityNotFoundException ex)
{
    //Chrome browser not installed
    intent.SetPackage(null);
    context.StartActivity(intent1);
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM