I have an actvity called SearchActivity. It has a searchbar and 4 tabs with Webviews. When I enter text and click on search, all the tabs are loading respective urls that I'm passing to them. But when I click on back button I want all the webviews to go back to the previous page, instead the activity closes. I've tried the below code, but it doesn't work. This the code of SearchActivity
public boolean onKeyDown(int keyCode, KeyEvent event) {
int count = getFragmentManager().getBackStackEntryCount();
if (count != 0 && (keyCode == KeyEvent.KEYCODE_BACK) && webView.canGoBack()) {
webView.goBack();
getFragmentManager().popBackStack();
//additional code
} else {
super.onBackPressed();
}
return super.onKeyDown(keyCode, event);
}