/// <summary> /// Called when an activity you launched exits, giving you the requestCode you started it with, /// the resultCode it returned, and any additional data from it. The resultCode will be <see cref="Result.Canceled"/> /// if the activity explicitly returned that, didn't return any result, or crashed during its operation.<br/> /// You will receive this call immediately before OnResume() when your activity is re-starting. /// </summary> /// <param name="requestCode">The integer request code originally supplied to <seealso cref="Activity.StartActivityForResult(Intent, int)"/>, allowing you to identify who this result came from.</param> /// <param name="resultCode">The <see cref="Result"/> returned by the child activity through its <see cref="Activity.SetResult(Result)"/>.</param> /// <param name="data">An Intent, which can return result data to the caller (various data can be attached to Intent "extras").</param> protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { if (resultCode != Result.Ok) { return; } switch (requestCode) { case CameraExtensions.ImageResult: CameraExtensions.OnCameraResult(); break; case CameraExtensions.GalleryResult: CameraExtensions.OnGalleryResult(data.Data); break; case VideoRecordingExtensions.VideoResult: VideoRecordingExtensions.OnNewVideoResult(data.Data); break; case VideoRecordingExtensions.VideoGalleryResult: VideoRecordingExtensions.OnVideoResult(data.Data); break; case VideoPlaybackExtensions.VideoPlayerResult: VideoPlaybackExtensions.OnVideoPlaybackResult(); break; } }
internal static bool HandleUrl(Link link, bool createBrowserView, IMXView fromView) { if (link?.Address == null) { return(false); } var queryIndex = link.Address.IndexOf('?'); if (queryIndex > 0) { var queryString = link.Address.Substring(queryIndex).Split('#')[0]; link.Parameters = HttpUtility.ParseQueryString(queryString).ToDictionary(k => k.Key, v => v.Value); } if (link.Address.StartsWith("app:")) { link.Address = link.Address.Substring(4); } if (link.Address.StartsWith(MailToExtensions.Scheme)) { MailToExtensions.Launch(link); } else if (link.Address.StartsWith(TelephoneExtensions.Scheme) || link.Address.StartsWith(TelephoneExtensions.CallToScheme)) { TelephoneExtensions.Launch(link); } else if (link.Address.StartsWith(CameraExtensions.Scheme)) { CameraExtensions.Launch(link); } else if (link.Address.StartsWith(AudioPlaybackExtensions.Scheme)) { AudioPlaybackExtensions.Launch(link); } else if (link.Address.StartsWith(AudioRecordingExtensions.Scheme)) { AudioRecordingExtensions.Launch(link); } else if (link.Address.StartsWith(VideoPlaybackExtensions.Scheme)) { VideoPlaybackExtensions.Launch(link); } else if (link.Address.StartsWith(VideoRecordingExtensions.Scheme)) { VideoRecordingExtensions.Launch(link); } else if (link.Address.StartsWith("javascript:")) { return(false); } else if (link.Address.StartsWith("http") && link.RequestType != RequestType.NewWindow) { if (!createBrowserView && string.IsNullOrEmpty(link.ConfirmationText)) { return(false); } Navigate(link, fromView); } else if (iApp.Instance.NavigationMap.MatchUrl(link.Address)?.Controller != null) { Navigate(link, fromView); } else { if (link.Address.StartsWith("/")) { link.Address = "file://" + link.Address; } var externalIntent = Intent.ParseUri(link.Address, IntentUriType.Scheme); externalIntent.AddFlags(ActivityFlags.NewTask); if (MainActivity.PackageManager.QueryIntentActivities(externalIntent, PackageInfoFlags.MatchDefaultOnly).Count > 0) { MainActivity.StartActivity(externalIntent); return(true); } // Launch external app by package name externalIntent = MainActivity.PackageManager.GetLaunchIntentForPackage(link.Address); if (MainActivity.PackageManager.QueryIntentActivities(externalIntent, PackageInfoFlags.MatchDefaultOnly).Count > 0) { MainActivity.StartActivity(externalIntent); return(true); } Device.Log.Error("Unable to handle url: " + link.Address); return(false); } return(true); }