网址多次在webview中显示

时间:2018-05-25 06:49:50

标签: android webview

我有一个Android应用程序,只是在一个显示网址的webview中,在测试网站上一切正常但是当我们切换到生产环境时,由于某种原因,网站显示3次低于另一个,是有谁知道可能会导致什么?它有时不会发生。

我检查过,我没有调用多个mWebview.loadUrl()onPageStarted() onPageFinished()只被调用一次。

我将此设置添加到我的网页视图中:

webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setAppCacheEnabled(true);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setDomStorageEnabled(true);

    mWebView.clearCache(true);

不确定是否有任何这些设置可能是问题的原因。

mWebView.setWebViewClient(new WebViewClient() {
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, final String url) {

            String urlToLoad;
            urlToLoad = redirectUrl(url);

            if (url.equals(Constants.ANDEN_LATERAL_NOMBRAMIENTO))
                enableNombramientoSearch();
            else
                disableNombramientoSearch();

            view.loadUrl(urlToLoad);
            Log.i("info load", "load shouldOverrideUrlLoading");
            return false;
        }

@Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            super.onPageStarted(view, url, favicon);

            Log.i("info load", "load onPageStarted");
            if (!mProgress.isShowing())
                mProgress.show();

        }

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

            Log.i("info load", "load onPageFinished");

            if (mProgress != null) {
                mProgress.dismiss();
            }
        }

        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {

            Log.i("info load", "load onReceivedError");
            String error = description;
        }

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.webview_layout);
    getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    getSupportActionBar().setCustomView(R.layout.centered_title_action_bar);
    ButterKnife.bind(this);

    mProgress = new ProgressDialog(WebviewActivity.this);
    mProgress.setMessage(getString(R.string.loading_label));

    mActionBarTitle = (TextView) getSupportActionBar().getCustomView().findViewById(R.id.actionBarTitle);

    initWebview();

    registerReceiver(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE));
    mDownloadManager = (DownloadManager) getSystemService(Context.DOWNLOAD_SERVICE);
}

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/background"
android:orientation="vertical">

<WebView
    android:id="@+id/webview"
    android:layout_width="match_parent"
    android:layout_height="0dp"
    android:layout_weight="0.9"/>


<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_gravity="center_vertical"
    android:paddingBottom="12dp"
    android:paddingTop="12dp">

    <TextView
        android:id="@+id/circularesBtn"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:text="@string/circulares_label"
        android:layout_gravity="center"
        android:gravity="center"
        android:drawablePadding="16dp"
        android:drawableTop="@drawable/ic_speaker"
        android:textSize="12sp"
        android:textColor="@android:color/white"
        android:background="@drawable/selector_textview"
        android:layout_weight="1"/>

    <TextView
        android:id="@+id/tablonOperacionesBtn"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:layout_gravity="center"
        android:layout_weight="1"
        android:drawablePadding="16dp"
        android:drawableTop="@drawable/ic_notepad"
        android:gravity="center"
        android:paddingTop="10dp"
        android:text="@string/tablon_operaciones_label"
        android:textColor="@android:color/white"
        android:textSize="12sp" />

    <TextView
        android:id="@+id/espacioSindicalBtn"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:text="@string/espacio_sindical_label"
        android:layout_gravity="center"
        android:gravity="center"
        android:drawablePadding="16dp"
        android:drawableTop="@drawable/ic_conversation"
        android:paddingTop="10dp"
        android:textSize="12sp"
        android:textColor="@android:color/white"
        android:layout_weight="1"/>

    <TextView
        android:id="@+id/publicacionesNombramientoBtn"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:text="@string/nombramiento_label"
        android:layout_gravity="center"
        android:gravity="center"
        android:drawablePadding="16dp"
        android:drawableTop="@drawable/ic_folder"
        android:paddingTop="10dp"
        android:textSize="12sp"
        android:textColor="@android:color/white"
        android:layout_weight="1"/>

    <TextView
        android:id="@+id/cerrarBtn"
        android:layout_width="0dp"
        android:layout_height="match_parent"
        android:text="@string/cerrar_label"
        android:layout_gravity="center"
        android:gravity="center"
        android:drawablePadding="16dp"
        android:drawableTop="@drawable/ic_home"
        android:paddingTop="10dp"
        android:textSize="12sp"
        android:textColor="@android:color/white"
        android:layout_weight="1"/>

</LinearLayout>

Sample of the problem

0 个答案:

没有答案