为 Xamarin.Android 中的文件获取内容 uri 的最佳做法是什么?

What is the best practice for getting a content-uri for a file in Xamarin.Android?

我已经通过以下方式在我的清单中注册了一个 FileProvider:

<provider android:name="android.support.v4.content.FileProvider"
          android:authorities="${applicationId}.provider"
          android:exported="false" android:grantUriPermissions="true">
  <meta-data android:name="android.support.FILE_PROVIDER_PATHS"
             android:resource="@xml/provider_paths" />
</provider>

现在,我想获取该文件的 URI 以传递给另一个应用程序以打开该文件。我试过了:

Intent viewIntent = new Intent(Intent.ActionView);
Java.IO.File document = new Java.IO.File(filePath);
Android.Net.Uri contentUri = FileProvider.GetUriForFile(
    _context, Android.Support.FILE_PROVIDER_PATHS, document);

viewIntent.SetDataAndType(contentUri, GetMimeType(document));
viewIntent.SetFlags(ActivityFlags.NewTask);
viewIntent.AddFlags(ActivityFlags.GrantReadUriPermission);
Intent chooser = Intent.CreateChooser(viewIntent,
    "Which program shall open the file?");
chooser.SetFlags(ActivityFlags.NewTask);
chooser.AddFlags(ActivityFlags.GrantReadUriPermission);

_context.StartActivity(chooser);

不幸的是,我似乎不能这样称呼Android.Support.FILE_PROVIDER_PATHS。如何尽可能干净地获取我的 URI?

_context.PackageName + ".provider" 完成工作(_contextAndroid.Content.Context):

Intent viewIntent = new Intent(Intent.ActionView);
Java.IO.File document = new Java.IO.File(filePath);
Android.Net.Uri contentUri = FileProvider.GetUriForFile(
    _context, Android.Support.FILE_PROVIDER_PATHS, document);

viewIntent.SetDataAndType(contentUri, GetMimeType(document));
viewIntent.SetFlags(ActivityFlags.NewTask);
viewIntent.AddFlags(ActivityFlags.GrantReadUriPermission);
Intent chooser = Intent.CreateChooser(viewIntent,
    "Which program shall open the file?");
chooser.SetFlags(ActivityFlags.NewTask);
chooser.AddFlags(ActivityFlags.GrantReadUriPermission);

_context.StartActivity(chooser);