I'm using onBackPressed() method in my app in few places. In every place I want this method to do other stuff. When user is in X layout I want to Back button does somethink else than in Y layout, so I'm thinking that the best solution would be to use arguments in onBackPressed method. For example in X onBackPressed(0); and in Y onBackPressed(1); etc.
@Override
public void onBackPressed(int c){
if(c==0)Toast.makeText(getApplicationContext(), "This is X", Toast.LENGTH_SHORT).show();
if (c==1)Toast.makeText(getApplicationContext(), "This is Y", Toast.LENGTH_SHORT).show();
}
But it does not work. Do You have any ideas what can I do to make it work ? Or is there any better solution for this problem?
c
when it has never ever ever ever heard of it before (ever) and has no idea what it is supposed to represent ?