Activity started with startActivityForResult() not returning to calling Activity

前端 未结 3 1083
悲哀的现实
悲哀的现实 2021-01-17 21:22

I have 3 Activities - A, B, and C.

In a nutshell, Activity A starts Activity B, then A also starts Activity C and

3条回答
  •  遇见更好的自我
    2021-01-17 21:38

    I don't think you should use getApplicationContext() in the intent.

    From the developer website.

    getApplicationContext()
    Return the context of the single, global Application object of the current process.
    

    When you you startActivityForResult() it tries to return to the activity specified in the intent, which you are providing as the global application context.

    If you have an ActivityB then you should call it like

    Intent intent = new Intent(ActivityB.this, ActivityC.class);
    startActivityForResult(intent, 0);
    

    Then it will try to return to ActivityB when ActivityC is done.

提交回复
热议问题