Hello,
For using those APIs you mentioned, you could refer to the following documentations:
AndroidX.Core.View
- OnApplyWindowInsetsListener
- [ViewCompat.SetOnApplyWindowInsetsListener](https://developer.android.google.cn/reference/androidx/core/view/ViewCompat#setOnApplyWindowInsetsListener(android.view.View,androidx.core.view.OnApplyWindowInsetsListener\))
AndroidX.Core.Content:
- [ContextCompat.CheckSelfPermission](https://developer.android.google.cn/reference/kotlin/androidx/core/content/ContextCompat#checkSelfPermission(android.content.Context,java.lang.String\))
- [FileProvider.GetUriForFile](https://developer.android.google.cn/reference/androidx/core/content/FileProvider#getUriForFile(android.content.Context,java.lang.String,java.io.File\))
And here are the samples of using the APIs in Xamarin.Forms on Android platform:
Implement IOnApplyWindowInsetsListener:
public class RootViewDeferringInsetsCallback : WindowInsetsAnimationCompat.Callback, IOnApplyWindowInsetsListener
{
public RootViewDeferringInsetsCallback(int dispatchMode) : base(dispatchMode)
{
}
public WindowInsetsCompat OnApplyWindowInsets(View v, WindowInsetsCompat insets)
{
}
public override WindowInsetsCompat OnProgress(WindowInsetsCompat insets, IList<WindowInsetsAnimationCompat> runningAnimations)
{
}
}
ViewCompat.SetOnApplyWindowInsetsListener:
RootViewDeferringInsetsCallback callback = new RootViewDeferringInsetsCallback(WindowInsetsAnimationCompat.Callback.DispatchModeStop);
ViewCompat.SetOnApplyWindowInsetsListener(your_view, callback);
ContextCompat.CheckSelfPermission:
var selfPermission = ContextCompat.CheckSelfPermission(this, Manifest.Permission.Camera);
if (selfPermission == Permission.Granted)
{
}
else
{
}
FileProvider.GetUriForFile:
At first, please refer to FileProvider to configure your FileProvider.
Then, in you Xamarin project, you could use the following code to call FileProvider.GetUriForFile:
File imagePath = new File(FilesDir, "my_images");
File newFile = new File(imagePath, "default_image.jpg");
Android.Net.Uri contentUri = FileProvider.GetUriForFile(this, "com.mydomain.fileprovider", newFile);
Best Regards,
Alec Liu.
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.