您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

36 行
1.0 KiB

  1. #if ANDROID
  2. using AndroidX.Activity;
  3. using MauiBlazorPermissionsExample.Platforms.Android;
  4. #endif
  5. using Microsoft.AspNetCore.Components.WebView;
  6. using Microsoft.Maui.Platform;
  7. using System;
  8. namespace HybridApp
  9. {
  10. public partial class MainPage : ContentPage
  11. {
  12. #if ANDROID
  13. private partial void BlazorWebViewInitialized(object? sender, BlazorWebViewInitializedEventArgs e)
  14. {
  15. if (e.WebView.Context?.GetActivity() is not ComponentActivity activity)
  16. {
  17. throw new InvalidOperationException($"The permission-managing WebChromeClient requires that the current activity be a '{nameof(ComponentActivity)}'.");
  18. }
  19. e.WebView.Settings.JavaScriptEnabled = true;
  20. e.WebView.SetWebChromeClient(new PermissionManagingBlazorWebChromeClient(e.WebView.WebChromeClient!, activity));
  21. }
  22. #else
  23. private partial void BlazorWebViewInitialized(object? sender, BlazorWebViewInitializedEventArgs e)
  24. {
  25. }
  26. #endif
  27. }
  28. }