如何停止在Android的WebView中的自动刷新Android、WebView

由网友(OゞA↘da調)分享简介:荫使用我的应用程序的WebView它加载远程url.It是能够加载每当我试图背景之间进行切换我的应用程序到前台远程URL successfully.But,有时我其中包含的WebView是当前活动refreshing.How以我避开我的WebView清爽当我从背景切换到foreground.Iam在我Activity....

荫使用我的应用程序的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);
        }

    });
阅读全文

相关推荐

最新文章