diff --git a/DeviceTests/DeviceTests.Android/Properties/AndroidManifest.xml b/DeviceTests/DeviceTests.Android/Properties/AndroidManifest.xml index 7d1546089..04e3c1b54 100644 --- a/DeviceTests/DeviceTests.Android/Properties/AndroidManifest.xml +++ b/DeviceTests/DeviceTests.Android/Properties/AndroidManifest.xml @@ -6,11 +6,9 @@ - - + - diff --git a/Samples/Samples.Android/Properties/AndroidManifest.xml b/Samples/Samples.Android/Properties/AndroidManifest.xml index 2e52e0fbb..0666d3f0b 100644 --- a/Samples/Samples.Android/Properties/AndroidManifest.xml +++ b/Samples/Samples.Android/Properties/AndroidManifest.xml @@ -8,8 +8,6 @@ - - diff --git a/Xamarin.Essentials/AppActions/AppActions.android.cs b/Xamarin.Essentials/AppActions/AppActions.android.cs index 1c4c78361..68b599993 100644 --- a/Xamarin.Essentials/AppActions/AppActions.android.cs +++ b/Xamarin.Essentials/AppActions/AppActions.android.cs @@ -42,6 +42,7 @@ static AppAction ToAppAction(this ShortcutInfo shortcutInfo) => const string extraAppActionTitle = "EXTRA_XE_APP_ACTION_TITLE"; const string extraAppActionSubtitle = "EXTRA_XE_APP_ACTION_SUBTITLE"; const string extraAppActionIcon = "EXTRA_XE_APP_ACTION_ICON"; + internal const string extraAppActionHandled = "EXTRA_XE_APP_ACTION_HANDLED"; internal static AppAction ToAppAction(this Intent intent) => new AppAction( diff --git a/Xamarin.Essentials/FilePicker/FilePicker.android.cs b/Xamarin.Essentials/FilePicker/FilePicker.android.cs index b6a576fd8..2d32912e9 100644 --- a/Xamarin.Essentials/FilePicker/FilePicker.android.cs +++ b/Xamarin.Essentials/FilePicker/FilePicker.android.cs @@ -11,10 +11,6 @@ public static partial class FilePicker { static async Task> PlatformPickAsync(PickOptions options, bool allowMultiple = false) { - // we only need the permission when accessing the file, but it's more natural - // to ask the user first, then show the picker. - await Permissions.EnsureGrantedAsync(); - // Essentials supports >= API 19 where this action is available var action = Intent.ActionOpenDocument; diff --git a/Xamarin.Essentials/MediaPicker/MediaPicker.android.cs b/Xamarin.Essentials/MediaPicker/MediaPicker.android.cs index 2c4a22dfd..261aa9880 100644 --- a/Xamarin.Essentials/MediaPicker/MediaPicker.android.cs +++ b/Xamarin.Essentials/MediaPicker/MediaPicker.android.cs @@ -20,10 +20,6 @@ static Task PlatformPickVideoAsync(MediaPickerOptions options) static async Task PlatformPickAsync(MediaPickerOptions options, bool photo) { - // We only need the permission when accessing the file, but it's more natural - // to ask the user first, then show the picker. - await Permissions.EnsureGrantedAsync(); - var intent = new Intent(Intent.ActionGetContent); intent.SetType(photo ? FileSystem.MimeTypes.ImageAll : FileSystem.MimeTypes.VideoAll); diff --git a/Xamarin.Essentials/Permissions/Permissions.ios.tvos.watchos.cs b/Xamarin.Essentials/Permissions/Permissions.ios.tvos.watchos.cs index e4af5e548..0e1af4a67 100644 --- a/Xamarin.Essentials/Permissions/Permissions.ios.tvos.watchos.cs +++ b/Xamarin.Essentials/Permissions/Permissions.ios.tvos.watchos.cs @@ -186,9 +186,9 @@ void LocationAuthCallback(object sender, CLAuthorizationChangedEventArgs e) } del.AuthorizationStatusChanged -= LocationAuthCallback; - tcs.TrySetResult(GetLocationStatus(whenInUse)); locationManager?.Dispose(); locationManager = null; + tcs.TrySetResult(GetLocationStatus(whenInUse)); } catch (Exception ex) { diff --git a/Xamarin.Essentials/PhoneDialer/PhoneDialer.ios.cs b/Xamarin.Essentials/PhoneDialer/PhoneDialer.ios.cs index dfda3b357..57df56301 100644 --- a/Xamarin.Essentials/PhoneDialer/PhoneDialer.ios.cs +++ b/Xamarin.Essentials/PhoneDialer/PhoneDialer.ios.cs @@ -11,12 +11,12 @@ public static partial class PhoneDialer internal static bool IsSupported => UIApplication.SharedApplication.CanOpenUrl(CreateNsUrl(new string('0', 10))); - static async void PlatformOpen(string number) + static void PlatformOpen(string number) { ValidateOpen(number); var nsUrl = CreateNsUrl(number); - await Launcher.PlatformOpenAsync(nsUrl); + Launcher.PlatformOpenAsync(nsUrl); } static NSUrl CreateNsUrl(string number) => new NSUrl(new Uri($"tel:{number}").AbsoluteUri); diff --git a/Xamarin.Essentials/Platform/Platform.android.cs b/Xamarin.Essentials/Platform/Platform.android.cs index dd47f40ec..6bbd80d2e 100644 --- a/Xamarin.Essentials/Platform/Platform.android.cs +++ b/Xamarin.Essentials/Platform/Platform.android.cs @@ -110,8 +110,11 @@ public static void OnResume(Activity activity = null) static void CheckAppActions(AndroidIntent intent) { - if (intent?.Action == Intent.ActionAppAction) + if (intent?.Action == Intent.ActionAppAction && !intent.GetBooleanExtra(AppActions.extraAppActionHandled, false)) { + // prevent launch intent getting handled on activity resume + intent.PutExtra(AppActions.extraAppActionHandled, true); + var appAction = intent.ToAppAction(); if (!string.IsNullOrEmpty(appAction?.Id))