【问题标题】:Android Webview: "Uncaught TypeError: Cannot read property 'getItem' of null"Android Webview:“未捕获的 TypeError:无法读取属性 'getItem' of null”
【发布时间】:2016-01-09 20:26:34
【问题描述】:

我正在创建一个简单的 android 应用程序,它有一个应该显示 url 的 webview。当我将 url 作为 google.com 或 facebook.com 提供时,它会正确加载,但是当我提供 url(qbo.intuit.com) 时,它不会加载并给出“未捕获的 TypeError:无法读取属性 'getItem' 为 null “ 错误。 我在这里很好地粘贴了我的代码。我正在使用编译 sdk 版本:API 22:Android 5.1 (Lollipop),版本-Android Studio 1.4,内部版本号:AI-141.2288178,Android SDK 工具:24.4.0,jdk1.7.0_80。存在类似的问题,但对我没有帮助。请帮助我是android的新手。 MainActivity.java

 @Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    String url= "https://qbo.intuit.com/";
    WebView view= (WebView) this.findViewById(R.id.webView);

     final WebViewClient client = new WebViewClient() {

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            view.loadUrl(url);
            return false;
        }

    };

        WebSettings settings = view.getSettings();
        settings.setJavaScriptEnabled(true);
    view.setWebViewClient(client);
        view.loadUrl(url);


}

AndriodManifest.xml

<?xml version="1.0" encoding="utf-8"?>

<uses-permission android:name="android.permission.INTERNET"/>

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

【问题讨论】:

    标签: android webview


    【解决方案1】:

    你需要做的

    WebSettings settings = webView.getSettings();
    settings.setDomStorageEnabled(true);
    

    查看详情 ERROR/Web Console: Uncaught TypeError: Cannot call method 'getItem' of null at http://m.youtube.com/:844

    【讨论】:

    • 这帮助我解决了 Inline Manual 无法在 Android WebView 中启动的问题。谢谢!
    • 这对我有帮助!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-06-23
    • 1970-01-01
    • 2015-06-18
    • 2022-11-20
    • 2022-11-24
    • 2022-12-20
    • 1970-01-01
    相关资源
    最近更新 更多