Android Webview: “ Uncatch TypeError: Can not read property‘ getItem’of null”

我正在创建一个简单的安卓应用程序,它有一个网络视图,应该显示一个网址。当我把 url 设置为 google.com 或 facebook.com 时,它会正常加载,但是当我设置 url (qbo.utiit.com)时,它不会加载,并且会出现“ Uncatch TypeError: Can not read property‘ getItem’of null”错误。 我在这里粘贴我的代码很好。我正在使用 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。类似的问题也存在,但对我没有帮助。请帮帮我,我是机器人的新手。 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>

42413 次浏览

you need to do

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

see details ERROR/Web Console: Uncaught TypeError: Cannot call method 'getItem' of null at http://m.youtube.com/:844

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

this two line of code you add your Activity then all js,jquery file in the add-in URL is open in your WebView