How to exit a webview (android)?
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();
}
}
};
精彩评论