How to return a result through multiple activities

前端 未结 4 1665
南方客
南方客 2020-12-12 13:59

in some part of my application there is a structure of activities like this:

\"enter<

4条回答
  •  攒了一身酷
    2020-12-12 14:20

    I know this is a really old question but I wanted to put in a valid solution, use onNewIntent() and treat it as onActivityResult().

    In activity D you would structure your intent as

    Intent intent = new Intent(yourContext, Activity_A.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.putExtra("someName", data);
    startActivity(intent);
    finish();
    

    and then in Activity_A

    @Override
    protected void onNewIntent(Intent intent) {
        super.onNewIntent(intent);
        // update your UI
        intent.getSerializableExtra(...
    }
    

提交回复
热议问题