如何停止在Android的WebView中的自动刷新 [英] How to stop automatic refreshing of WebView in Android

查看:1483
本文介绍了如何停止在Android的WebView中的自动刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

荫使用我的应用程序的WebView它加载远程url.It是能够加载每当我试图背景之间进行切换我的应用程序到前台远程URL successfully.But,有时我其中包含的WebView是当前活动refreshing.How以我避开我的WebView清爽当我从背景切换到foreground.Iam在我Activity.May的应用程序版本不是在所有使用onResume()被在AndroidManifest.xml文件2.2.My活动代码如下:

Iam using WebView in my application which loads a remote url.It is able to load the remote url successfully.But whenever i trying to switch my application between background to foreground,sometimes my Current Activity which contains the WebView is refreshing.How to i avoid refreshing of my WebView when i switch from background to foreground.Iam not at all using onResume() in my Activity.May app version is 2.2.My Activity tag in AndroidManifest.xml file is as follows.

    <activity 
        android:name=".Main"
        android:screenOrientation="portrait" android:configchanges="orientation|keyboardHidden|locale|uiMode|mcc|mnc|touchscreen|keyboard">
    </activity>

感谢和放大器;问候,
 Venkat在

Thanks&Regards, Venkat.

推荐答案

尝试重写WebViewClient,是这样的:

Try to override WebViewClient, something like:

        webView.setWebViewClient(new WebViewClient(){
    private boolean alreadyLoaded = false;  
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
                if (alreadyLoaded)
                   return;
                alreadyLoaded = true;
                super.onPageStarted(view,url,favicon);
        }

        @Override
        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
            super.onReceivedError(view, errorCode, description, failingUrl);

        }


        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
        }

    });

这篇关于如何停止在Android的WebView中的自动刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆