如何以实用的方式关闭FinestWebView?

时间:2017-07-20 08:08:12

标签: java android webview

我正在使用FinestWebView,我想在自动加载特定网址后关闭它。我没有找到任何关闭它的方法 我尝试过:

FinestWebView.Builder fn = null;
                        fn = new FinestWebView.Builder(getActivity()).
                                setCustomAnimations(R.anim.enter, R.anim.exit, R.anim.pop_enter, R.anim.pop_exit).setWebViewListener(new WebViewListener() {
                            @Override
                            public void onPageStarted(String url) {
                                super.onPageStarted(url);
                                if (url.equalsIgnoreCase(//myurl//)) ;
                                {
                                  //here i want to close 

                                }
                            }
                        }).backPressToClose(true);
                        ;
                        fn.show(url);

2 个答案:

答案 0 :(得分:0)

@Override
public void onActivityCreated(Activity activity, Bundle bundle) {
    if (activity instanceof FinestWebViewActivity) {
        mCurrentWebViewActivity = activity;
    }
}

    final FinestWebView.Builder builder = new FinestWebView.Builder(getActivity());
    builder.setWebViewListener(new WebViewListener() {
        @Override
        public void onPageStarted(String url) {
            super.onPageStarted(url);

            if (url.startsWith(Constants.THANK_YOU_PAGE)) {
                Activity webViewActivity = AppController.getInstance().getCurrentWebViewActivity();
                if (webViewActivity != null) {
                    webViewActivity.finish();
                }
            }
        }
    });
    builder.show(url);

答案 1 :(得分:0)

过程很简单,只需当前可见的活动,检查intanse,如果与FinestWebViewActivity相匹配,请完成。

final FinestWebView.Builder builder = new FinestWebView.Builder(AddBalanceActivity.this);

                    builder.titleDefault("Recharge Evaly Account")
                            .webViewBuiltInZoomControls(true)
                            .webViewDisplayZoomControls(true)
                            .dividerHeight(0)
                            .gradientDivider(false)
                            .setCustomAnimations(R.anim.activity_open_enter, R.anim.activity_open_exit,
                                    R.anim.activity_close_enter, R.anim.activity_close_exit)
                            .setWebViewListener(new WebViewListener() {

                                public void onPageFinished(String url) {
                                    super.onPageStarted(url);


                                    if (url.contains("url you want to match")){

                                        if(getApplicationContext() instanceof  FinestWebViewActivity)
                                            ((FinestWebViewActivity)getApplicationContext()).finish();

                                    }
                                }
                            }).show(purl);