相关疑难解决方法(0)

Android Webview:"未捕获的TypeError:无法读取null的属性'getItem'"

我正在创建一个简单的Android应用程序,它有一个webview,应该显示一个网址.当我将网址添加为google.com或facebook.com时,它会正确加载,但是当我提供我的网址(qbo.intuit.com)时,它不会加载并提供"未捕获的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

 @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);


}
Run Code Online (Sandbox Code Playgroud)

AndriodManifest.xml

<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)

<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>
Run Code Online (Sandbox Code Playgroud)

android webview

58
推荐指数
1
解决办法
2万
查看次数

Android - 在应用程序关闭后使Webview DomStorage持续存在

我正在开发一个使用Webview来显示数据的Android应用程序.我在webview中使用的网站使用HTML 5的localStorage API.

要启用此功能,我已将webview设置设置为:

webview.getSettings().setDomStorageEnabled(true);
webview.getSettings().setJavaScriptEnabled(true);
Run Code Online (Sandbox Code Playgroud)

所以localStorage API工作,但当我关闭应用程序(并终止进程)时,localStorage被完全擦除,当我重新加载它时,我的所有数据都丢失了.

我的问题很简单:即使关闭应用程序,如何使Web视图的DomStorage持续存在?

谢谢你所有未来的答案.

android persistent webview local-storage

23
推荐指数
3
解决办法
2万
查看次数

Javascript无法在WebView Activity中运行

我有一个只有一个WebView的Activity ,它包含HTML,CSS和Javascript代码.

似乎有与问题访问Java脚本屏幕尺寸的看法.LogCat说:

(Tag: Web Console): Uncaught TypeError: Cannot call method 'getWidth' of undefined 
at file:///android_asset/Prospekte/grund/html5-player/js/epaper-mobile.js:20
Run Code Online (Sandbox Code Playgroud)

当我查看js文件时,有: var f=this.body.getWidth();

奇怪的是,有时代码有效.电子报很好.但大部分时间都有这个错误.

    setContentView(R.layout.prospekt_layout);
    final Activity activity = this;

    mWebView = (WebView) findViewById(R.id.prospekt_webview);
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setDomStorageEnabled(true);
    mWebView.setWebChromeClient(new WebChromeClient() {
    public void onProgressChanged(WebView view, int progress) {
        activity.setProgress(progress * 1000);
      }
    });

    mWebView.setWebViewClient(new WebViewClient() {
        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl)
        {
            // Handle the error
        }

        @Override
        public boolean …
Run Code Online (Sandbox Code Playgroud)

javascript android webview

9
推荐指数
1
解决办法
2万
查看次数

加载www.google.com时,WebView会导致未捕获的TypeError

我正在使用WebView加载和呈现各种网站没有问题.奇怪的是,似乎导致错误的是www.google.com

加载此页面时,单击时"搜索"按钮不起作用.单击它时,我在LogCat中看到此错误(我还看到在页面加载期间报告的3个类似错误):

02-07 23:23:59.230:错误/ Web控制台(3721):未捕获的TypeError:无法在http://www.google.com/:342上调用null的方法'getItem'

我在onResume覆盖中启用JavaScript(以及其他内容):

    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setBuiltInZoomControls(true);
    settings.setLoadWithOverviewMode(true);
    settings.setUseWideViewPort(true);
    settings.setDatabaseEnabled(true);
Run Code Online (Sandbox Code Playgroud)

知道什么可能导致这些错误吗?谢谢!

android webview android-webview

6
推荐指数
1
解决办法
9531
查看次数

Android网页视图未加载网址

我在使用以下网址加载webview时遇到问题:

  1. http://www.walmart.com/

  2. http://mobile.walmart.com/

但两者都在webview中显示一个空白页面.

这里我附上了源代码.我该如何摆脱这个问题?

资源:

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.Window;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;

public class WEBVIEW_ITSELF extends Activity {

    WebView homeWeb;
    Button btnPlay;

    final Activity activity = this;
    static Context mContext;

    public boolean orandationChange = true;

    @Override
    protected void onPause() {
        super.onPause();

        orandationChange = false;
    }

    String urlchange;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
        setContentView(R.layout.i_webview);

        mContext = this;

        homeWeb = (WebView) findViewById(R.id.website_webview);
        homeWeb.getSettings().setJavaScriptEnabled(true);
        homeWeb.getSettings().setSupportZoom(true); // …
Run Code Online (Sandbox Code Playgroud)

android webview

1
推荐指数
1
解决办法
6015
查看次数