I have a webview and on click on some banner I am sending Intent.ACTION_VIEW to open browser or whatever user finds suitable like this:
w.setWebViewClient(new WebViewClient(){
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if (url != null && url.startsWith("http://")) {
view.getContext().startActivity(
new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
return true;
} else {
return false;
}
}
});
Now what I want is to find a way to know if user just hit back button before opening browser or he actually opened browser. I found this question but no solution there
You can do one thing which may not be the best practice to use but I think this will solve your problem
Initialization => boolean isPageLoading = false;
Now you have right indicator which will state, whether page is loading or not.
Now in your activity override back key press event
Note that you can change the behavior of this functionality by adding more boolean variables which will indicate different status info (such as whether page loading has started or not etc)
Hope this will solve issue you have raised