For example, there are активти1 , активти1 and активити3 , for example, I first switched to активити2 and from there to активити3 , but then I wanted to switch from активити3 to активити1 , I make the transition, but if I press the back button, I’ll switch to активити3 how to avoid this transition?
|
3 answers
In the second activity after startActivity call finish() . In the third startActivity , instead of startActivity , call finish() . Then this situation will not happen again.
|
If активити2 should never be on the activit stack, then you can simply set the android:noHistory="true" parameter android:noHistory="true" for this activit and do not fool with all sorts of finishes and starts.
An example of how this should look like in the manifest:
<activity android:name=".MainActivity" android:noHistory="true"> |
Alternatively, override the method of clicking on the "back" button and, instead of the standard action, launch the required activation:
@Override public void onBackPressed() { Log.i(LOG, "onBackPressed"); Intent intentToActivity = new Intent(this, ACTIVITy_CLASS_NAME.class); startActivity(intentToActivity); } |