Я использовал WebView для отображения данных с помощью URL, но мое представление диаграммы не загружается в веб-просмотре, я также даю все нижеуказанные разрешения для веб-просмотра.
Control.Settings.JavaScriptEnabled = true;
Control.Settings.LoadWithOverviewMode = true;
Control.Settings.DatabaseEnabled = true;
Control.Settings.UseWideViewPort = true;
Control.Settings.AllowFileAccess = true;
Control.Settings.AllowContentAccess = true;
Control.Settings.AllowFileAccessFromFileURLs = true;
Control.Settings.AllowUniversalAccessFromFileURLs = true;
Control.Settings.JavaScriptCanOpenWindowsAutomatically = true;
Control.Settings.DomStorageEnabled = true;
Control.VerticalScrollBarEnabled = true;
Control.SetWebViewClient(new WebClient(this));
class WebClient : WebViewClient
{
WebViewRendererForAndroid _renderer;
public WebClient(WebViewRendererForAndroid renderer)
{
_renderer = renderer ?? throw new ArgumentNullException("renderer");
}
public override bool ShouldOverrideUrlLoading(AWebView view, string url)
{
try
{
var Token = UserSettings.AccesToken;
Dictionary<String, String> headers = new Dictionary<String, String>();
headers.Add("Authorization", Token);
view.LoadUrl(url, headers);
}
catch (Exception ex)
{
}
return true;
}
public override void OnReceivedError(AWebView view, IWebResourceRequest request, WebResourceError error)
{
base.OnReceivedError(view, request, error);
}
public override void OnReceivedHttpError(AWebView view, IWebResourceRequest request, WebResourceResponse errorResponse)
{
base.OnReceivedHttpError(view, request, errorResponse);
var source = new UrlWebViewSource { Url = request.Url.ToString() };
var args = new WebNavigatedEventArgs(WebNavigationEvent.NewPage, source, request.Url.ToString(), WebNavigationResult.Failure);
_renderer.ElementController.SendNavigated(args);
}
public override void OnReceivedError(AWebView view, [GeneratedEnum] ClientError errorCode, string description, string failingUrl)
{
base.OnReceivedError(view, errorCode, description, failingUrl);
var source = new UrlWebViewSource { Url = failingUrl };
var args = new WebNavigatedEventArgs(WebNavigationEvent.NewPage, source, failingUrl, WebNavigationResult.Failure);
_renderer.ElementController.SendNavigated(args);
}
}