I have a WebView into which I'm loading the facebook sharer php page. This page doesn't have any form of confirmation, it simply closes the window once the user has either shared or cancelled.
Since it is loaded into a web view there is nothing to "close" perse, so, I need to detect the window trying to close and act on that callback.
From my various searches it appears that the way to handle this is via a WebChromeClient. So, I'm attempting the following, but the callback is never called. I am obviously missing something, but don't know what. It *feels like the onCloseWindow event should be Overriden, but that causes eclipse to complain (reasonably) that I need to super the instance, which the documentation doesn't seem to suggest is possible.
All help appreciated.
[EDIT] oh, and I just tried swapping the order of the actions, setting the WebChromeClient before calling the url, and (as I expected) that didn't alter the behavior in any way.
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
webview.setWebViewClient(new WebViewClient());
webview.loadUrl("http://www.facebook.com/sharer/sharer.php?u=http://EXTRACTED.com?img_id=abc");// + getIntent().getStringExtra("userId"));
WebChromeClient wbc = new WebChromeClient(){
public void onCloseWindow(Window w){
Log.d(TAG, "Window trying to close");
}
};
webview.setWebChromeClient(wbc);
Whats wrong with:
public void onCloseWindow(WebView w){
super.onCloseWindow(w);
Log.d(TAG, "Window trying to close");
}