Skip to content

Instantly share code, notes, and snippets.

@kodeshpa
Created June 29, 2011 20:42
Show Gist options
  • Save kodeshpa/1054898 to your computer and use it in GitHub Desktop.
Save kodeshpa/1054898 to your computer and use it in GitHub Desktop.
Workaround for NPE WebView.onWindowFocusChanged
/*
* Workaround for Null pointer exception in WebView.onWindowFocusChanged
*/
public class CustomWebView extends WebView {
public CustomWebView(Context context) {
super(context);
}
public CustomWebView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public CustomWebView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
public void onWindowFocusChanged(boolean hasWindowFocus) {
try{
super.onWindowFocusChanged(hasWindowFocus);
}catch(NullPointerException e){
// Catch null pointer exception
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment