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);
WebViewClient onPageFinished() | listen for a WebView finishing loading a URL. To know about the URL loaded or not in WebView have to use the webViewClient onPageFinished() method. A WebView to have a WebViewClient to make use of the onPageFinished event callback.
Add a close button and on its click set: webview. setVisibility(View. INVISIBLE); webview.
I did something similar: Just extend WebView and override onWindowVisibilityChanged . This way, the audio continues to play if the screen is locked or another app is opened. However, there will be no controls in the notification bar or on the lockscreen.
Web View is slower on both as compared to native android browser.
Whats wrong with:
public void onCloseWindow(WebView w){
super.onCloseWindow(w);
Log.d(TAG, "Window trying to close");
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With