Android back button problem

被刻印的时光 ゝ 提交于 2019-12-04 20:44:35

You can add finish() in the onStop() method of activity B.

This way, when the activity B will no longer be visible, it will be destroyed and removed from the stack.

  • Open app: A
  • Go to B: A, B
  • Go to C: A, C
  • Press back: A
  • Press back: exiting

When you go Activity B to Activity C first finish activity B then go activity C.

ex:-

finish();
Intent i2 = new Intent(Acttivity.B, Acttivity.C);
startActivity(i2);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!