You need to override back pressed somewhere in your activity
@Override
public void onBackPressed()
{
//Do whatever custom stuff you wish here
super.onBackPressed();
}
Then you may call backPressed in whatever way you may wish and wherever you may wish:
MyActivity.this.onBackPressed();