Xamarin(适用于Mac的Visual Studio社区,版本7.7.3)告诉我Android.Net.Uri没有Parse。实际上,它只能识别Android.Net.Uri.Builder和Android.Net.Uri.InterfaceConsts(编辑助手仅显示这两项)
行
Android.Net.Uri uri =新的Android.Net.Uri.Parse(“ ontracktechapp2://”);
失败,类型为“ Parse”,类型为“ Uri”不存在。 这是Xamarin Forms应用程序,显示的类是本机Android的一部分
using System.Collections.Generic;
using Android.Content;
using Android.Content.PM;
using FindApp2.Droid;
using myappnamespace;
using Xamarin.Forms.Platform.Android;
[assembly: Xamarin.Forms.Dependency(typeof(FindApp2Droid))]
namespace FindApp2.Droid
{
public class FindApp2Droid: IFindApp2
{
static FormsAppCompatActivity currentActivity = null;
public bool IsApp2Installed()
{
Android.Net.Uri uri = new Android.Net.Uri.Parse("myurlscheme://");
Intent intent = new Intent(Intent.ActionView, null);
intent.AddCategory(Intent.CategoryLauncher);
PackageManager pm = currentActivity.PackageManager;
List<ResolveInfo> resolvedActivities = (List <ResolveInfo>)pm.QueryIntentActivities(intent, 0);
return (resolvedActivities.Count > 0);
}
}
}