I\'m developing an Android application that uses a WebView to display the login page for Facebook. The page loads beautifully, and I\'m able to select the username/password
I spend a lot of time to solve this problem. Finally, I realized that it is not about WebView. In my case, I have a webview inside dialog. I want to handle back pressed button to cancel dialog and finish activity as well. And I wrote code below:
private void setOnBackPressed() {
this.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
dialog.dismiss();
activity.finish();
}
return true;
}
});
}
So, when I use the keyboard, this method reject all key presses somehow and then it doesn't appear on the text fields.
I only changed the return value to false. So, it worked properly.
Hope it helps!!
PS: this method is inside my dialog class that extends Dialog class