Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
Fixes #496
Browse files Browse the repository at this point in the history
Handle special Huawei devices
  • Loading branch information
jamesmontemagno committed Apr 2, 2018
1 parent f5c2b62 commit 237edad
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/Media.Plugin.Android/MediaPickerActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ protected override void OnSaveInstanceState(Bundle outState)
base.OnSaveInstanceState(outState);
}

const string HuaweiManufacturer = "Huawei";

/// <summary>
/// OnCreate
Expand Down Expand Up @@ -159,7 +159,21 @@ protected override void OnCreate(Bundle savedInstanceState)
pickIntent.AddFlags(ActivityFlags.GrantWriteUriPermission);
pickIntent.PutExtra(MediaStore.ExtraOutput, photoURI);
}
catch(Exception ex)
catch (Java.Lang.IllegalArgumentException iae)
{
//Using a Huawei device on pre-N. Increased likelihood of failure...
if (HuaweiManufacturer.Equals(Build.Manufacturer, StringComparison.CurrentCultureIgnoreCase) && (int)Build.VERSION.SdkInt < 24)
{
pickIntent.PutExtra(MediaStore.ExtraOutput, path);
}
else
{
System.Diagnostics.Debug.WriteLine($"Unable to get file location, check and set manifest with file provider. Exception: {iae}");

throw new ArgumentException("Unable to get file location. This most likely means that the file provider information is not set in your Android Manifest file. Please check documentation on how to set this up in your project.", iae);
}
}
catch (Exception ex)
{
System.Diagnostics.Debug.WriteLine($"Unable to get file location, check and set manifest with file provider. Exception: {ex}");

Expand Down

0 comments on commit 237edad

Please sign in to comment.