如果webview中的url相同,如何启动第三个活动

时间:2018-03-22 10:54:32

标签: android android-studio android-activity webview android-webview

如果webview中的url相同,如何启动第三个活动

例如我有webview 在我的webview中,如果网址是这样的

http://example.com/access.html

然后开始第三次活动

我该怎么做才能帮我解决这个问题  感谢

提前

这是我的webview代码

public class SecondActivity extends AppCompatActivity {

    private WebView wv1;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
        String url = getIntent().getStringExtra("url");
        wv1=(WebView)findViewById(R.id.webView);
        wv1.setWebViewClient(new WebViewClient());
        wv1.getSettings().setLoadsImagesAutomatically(true);
        wv1.getSettings().setJavaScriptEnabled(true);
        wv1.loadUrl(url);
    }




}

这是第二个活动的xml文件

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@color/colorPrimaryDark"

    tools:context="com.shuvro.barcodescanner.BarcodeScannerActivity">


    <WebView
        android:id="@+id/webView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</RelativeLayout>

2 个答案:

答案 0 :(得分:1)

 webView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageStarted(WebView view, String url, Bitmap 
      favicon) {
            super.onPageStarted(view, url, favicon);
       // write your logic here.
            if (url.equals(pdfWebURL)) {
                loadingIndicator.setVisibility(View.VISIBLE);
            }
        }

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

请在onPageStarted中写下你的逻辑。

答案 1 :(得分:0)

请尝试以下代码

java ***.jar