In one of my applications I am using fragment. Now I want to add exit alertbox on back key press but I am not able to get public void onBackPressed() method in Fragment extended class. How can I achieve this? My MainActivity extends FragmentActivity.
public void onBackPressed() {
super.onBackPressed();
alertbox("myappname", "Do You Want to Exit?");
}
But it does not display a dialog or if it displays it disappears in 1 second. What am I doing wrong.