小编Ste*_*ead的帖子

xamarin android webview不再使用httplistener检索本地提供的页面

我们有一个xamarin android应用程序,其中包含一个httplistener,它为在全屏webview中运行的单页应用程序提供html,js,css和json调用。从Xamarin 3.5开始,webview无法检索我们在端口31316上运行的本地主机地址。在此发行版之前,此功能正常运行。

从我所看到的情况来看,httplistener看起来很健康,因为我们可以正确地使用WebRequest库来调用它,这使我相信Webview发生了某些变化。

任何帮助将不胜感激。

以下是一个演示行为的示例应用程序:

using System;
using System.Net;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Webkit;
using Android.Widget;
using System.IO;
using System.Text;

namespace HttpListenerTest
{
    [Activity (Label = "HttpListenerTest", MainLauncher = true, Icon = "@drawable/icon")]
public class MainActivity : Activity
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);
        SetContentView(Resource.Layout.Main);
        StartService(new Intent(this, typeof(HttpListenerTestService)));

        var webView = (WebView)this.FindViewById<WebView>(Resource.Id.webview);
        webView.Settings.AllowFileAccess = true;
        webView.Settings.BlockNetworkLoads = false;
        webView.LoadUrl("http://localhost:31316/");
        //webView.LoadData (Activities.html, "text/html", "UTF-8");

        var button = FindViewById<Button>(Resource.Id.button1);
        button.Click += delegate
        {
            AlertDialog.Builder alert1;
            alert1 …
Run Code Online (Sandbox Code Playgroud)

android webview xamarin

5
推荐指数
0
解决办法
568
查看次数

标签 统计

android ×1

webview ×1

xamarin ×1