Skip going back to direct parent activity when pressed back

前端 未结 8 2030
伪装坚强ぢ
伪装坚强ぢ 2020-12-09 22:37

I have got a small problem in an Android app I am working on :

There are 3 activities namely A , B , C and the invocation is in the following order : A -> B -> C.

8条回答
  •  鱼传尺愫
    2020-12-09 22:59

    I think you should not break the normal flow. C should first return to B then A.

    Any way i am having solution of your problem. Register a broadcast receiver in A activity then from C send a broadcast to A. In A activity you can receive that broadcast and then clear the stack. This will automatically finish all child activities.

    Override onbackpress and don't call super in onbackpress instead send a broadcast to activity A.

提交回复
热议问题