Just override the onBackPressed() method and no need to call the super class of onBackPressed method or others..
@Override
public void onBackPressed()
{
}
Or pass your current activity into the onBackPressed() method.
@Override
public void onBackPressed()
{
startActivity(new Intent(this, myActivity.class));
finish();
}
Replace your require activity name to myActivity.
if you are using fragment then first of all call the callParentMethod() method
public void callParentMethod(){
context.onBackPressed(); // instead of context use getActivity or something related
}
then call the empty method
@Override
public void onBackPressed()
{
}