Application not open main activity when it was killed after pressing home button in android

前端 未结 8 1278
余生分开走
余生分开走 2020-12-31 21:08

In my Application, activity A is launcher activity, from A it called B and from B it called C, I have such more than 5 activities. In C when I press home button, and again o

8条回答
  •  有刺的猬
    2020-12-31 21:45

    on pressing home ,u have not finished activity it still exists in stack.only it goes to pause so use this.

    if you are calling activity B from an activity A.and C from B

    A->B

    use startactivityforresult from A

    and again B->C

    use startactivityforresult from B

    and when you want to exit from C then setResult(i.e. RESULT_OK) and finish C.and in OnActivityResult() in B,check if resultcode == RESULT_OK then again finish B and setresult(RESULT_OK) for A.same procedure will follow to finish A.

    this will exit you from the application.and application will start from A not from C.

提交回复
热议问题