In my android webview I want app to exit if back button is pressed only when user is on home page, but on any other page the back button should work normally and go back to previous session. I have build one php application which I'm showing to my users through android webview. Now if user opens the app, it will open the home page of my php application from where users can navigate through various option and then come back to home page, now here when users come to home page and press back button its going to previous page which I dont want. I want something like if the user is on home page of the app and press back button, it should just exit the app.
This is what I've tried for goback:
@Override public void onBackPressed() {
if (webView.canGoBack()) {
webView.goBack();
} else {
super.onBackPressed();
}
}