我已经为 Android 设备开发了一个使用 Xamarin 的应用程序。我正在使用 Xamarin.Essentials 包中的媒体选择器。在我的工作地点,我们有两种类型的设备 - 一种具有使用 Microsoft intunes 的工作配置文件端。该应用程序在其他设备上运行良好,但当我使用工作配置文件在设备上打开相机时崩溃。我已经要求清单中的相关权限。有人对这个有经验么?这是我第一次使用 Xamarin。我在下面包含了我的部分代码及其引发的错误。
亲切的问候
bool x = MediaPicker.IsCaptureSupported;
if(x == false)
{
await DisplayAlert("ok", "alert", "cancel");
}
var photo = await MediaPicker.CapturePhotoAsync();
var stream = await photo.OpenReadAsync();
newImage.Source = ImageSource.FromStream(() => stream);
java.lang.RuntimeException
java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3827)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:4003)
at android.app.servertransaction.LaunchActivityItem.execute (LaunchActivityItem.java:85)
at android.app.servertransaction.TransactionExecutor.executeCallbacks (TransactionExecutor.java:135)
at android.app.servertransaction.TransactionExecutor.execute (TransactionExecutor.java:95)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:2317)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:246)
at android.app.ActivityThread.main (ActivityThread.java:8595)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:602)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1130)
Caused by: java.lang.IllegalArgumentException:
at androidx.core.content.FileProvider.parsePathStrategy (FileProvider.java:606)
at androidx.core.content.FileProvider.getPathStrategy (FileProvider.java:579)
at androidx.core.content.FileProvider.getUriForFile (FileProvider.java:417)
at crc64a0e0a82d0db9a07d.IntermediateActivity.n_onCreate (Native Method)
at crc64a0e0a82d0db9a07d.IntermediateActivity.onCreate (IntermediateActivity.java:31)
at android.app.Activity.performCreate (Activity.java:8207)
at android.app.Activity.performCreate (Activity.java:8191)
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1309)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:3800)
更新:我想我可能需要为应用请求权限才能访问工作资料中的相机?这可能吗