无法读取null的属性

无法读取null的属性

本文介绍了Android Webview:“未捕获的TypeError:无法读取null的属性'getItem'"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个简单的android应用,该应用具有一个应显示网址的webview.当我将网址指定为google.com或facebook.com时,它会正确加载,但是当我提供我的网址(qbo.intuit.com)时,它不会加载并显示"Uncaught TypeError:无法读取属性'getItem'为null "错误.我在这里很好地粘贴了我的代码.我正在使用Compile 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

I am creating a simple android app which has a webview which should display a url. When I give the url as google.com or facebook.com it loads properly but when I give my url(qbo.intuit.com), it doesn't load and gives the "Uncaught TypeError: Cannot read property 'getItem' of null" error.I am pasting my code here well. I am using Compile sdk version: API 22: Android 5.1 (Lollipop), Version- Android Studio 1.4, Build Number: AI-141.2288178, Android SDK Tools: 24.4.0, jdk1.7.0_80. A similar question exists but it did not help me. Please help I am new to 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

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>

推荐答案

您需要做的

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

查看详细信息错误/Web控制台:未捕获TypeError:无法在http://m.youtube.com/:844

这篇关于Android Webview:“未捕获的TypeError:无法读取null的属性'getItem'"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 00:34