Skip to content
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
This repository was archived by the owner on Feb 26, 2023. It is now read-only.

Intent builder startForResult from fragment #723

@WonderCsabo

Description

@WonderCsabo

You've provided a nice Intent builder for starting Activities. One could use it like this:

MyActivity_.intent(getActivity()).startForResult(REQUEST_SEARCH);

However, if this is called from a Fragment, after the started Activity returns to this caller Fragment, onActivityResult will not get called! The generated code for startForResult looks like this:

public void startForResult(int requestCode) {
    if (context_ instanceof Activity) {
        ((Activity) context_).startActivityForResult(intent_, requestCode);
    } else {
        context_.startActivity(intent_);
    }
}

And this is the culprit. In this case the Activity version of startActivityForResult is called, not the Fragment version.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions