Since there are already many great solutions suggested, ill try to give a more dipictive explanation.
How to skip going back to the previous activity?
Remove the previous Activity from Backstack. Simple
How to remove the previous Activity from Backstack?
Call finish()
method
All the activities are stored in a Stack known as Backstack.
When you start a new Activity(startActivity(...)
) then the new Activity is pushed to top of the stack and when you press back button the Activity is popped from the stack.
One key point to note is that when the back button is pressed then finish();
method is called internally. This is the default behavior of onBackPressed() method.
ie A<--- C
Just add finish();
method after your startActvity(...)
in the Activity B
Intent i = new Intent(this, C.class);
startActivity(i);
finish();