コード例 #1
0
 /// <summary>
 /// Used to check whether there is a specialized handler for a given intent. </summary>
 /// <param name="intent"> The intent to check with. </param>
 /// <returns> Whether there is a specialized handler for the given intent. </returns>
 private static bool HasSpecializedHandlerIntents(Context context, Intent intent)
 {
     try
     {
         PackageManager      pm       = context.PackageManager;
         IList <ResolveInfo> handlers = pm.QueryIntentActivities(intent, Android.Content.PM.PackageInfoFlags.ResolvedFilter);
         if (handlers == null || handlers.Count == 0)
         {
             return(false);
         }
         foreach (ResolveInfo resolveInfo in handlers)
         {
             IntentFilter filter = resolveInfo.Filter;
             if (filter == null)
             {
                 continue;
             }
             if (filter.CountDataAuthorities() == 0 || filter.CountDataPaths() == 0)
             {
                 continue;
             }
             if (resolveInfo.ActivityInfo == null)
             {
                 continue;
             }
             return(true);
         }
     }
     catch (Exception e)
     {
         StringBuilder sb = new StringBuilder();
         sb.AppendLine("Runtime exception while getting specialized handlers");
         sb.Append("Exception = ");
         sb.Append(e.Message);
         Log.Error
         (
             Xamarin.Auth.CustomTabsConfiguration.CustomTabsHelperAndroidLogTag,
             sb.ToString()
         );
     }
     return(false);
 }