开发者

How to exit a webview (android)?

开发者 https://www.devze.com 2023-03-25 18:25 出处:网络
What I am trying to do is that when user click a开发者_运维技巧 button in a webview page, it starts a service and exit the webview(in animation way if possible).If you have only 1 activity you can sim

What I am trying to do is that when user click a开发者_运维技巧 button in a webview page, it starts a service and exit the webview(in animation way if possible).


If you have only 1 activity you can simply start the service and then call finish() on the activity. However, if you have multiple activities you have to make sure that you close them all (see also this post).


You can exit the webView when a specific link is reached. I believe this solution will work in this case.

 WebViewClient webViewClient = new WebViewClient() {

        @Override
        public void onPageFinished(WebView view, String url) {
            super.onPageFinished(view, url);
            Log.e("PAGE_URL", url);
            if(url.equals("your link...")){
                finish();

            }
        }
    };
0

精彩评论

暂无评论...
验证码 换一张
取 消