I am overriding the onBackPressed method in activity:
@Override
public void onBackPressed() {
super.onBackPressed();
}
And I am adding up fragments as follows:
fragmentManager.beginTransaction()
.add(R.id.frame_container, myFragment).addToBackStack("").commit();
The problem is my onBackPressed is not getting called in the activity. But when I change it to :
replace(R.id.frame_container, myFragment).addToBackStack("").commit();
it gets called as expected. I have to add the fragments. How to solve this issue?