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.

@OnActivityResult bug with multiple request codes #447

Description

@luxtau

Version: androidannotations-2.7.jar

Source code:

static final int ADD_ACCOUNT = 1, EDIT_ACCOUNT = 2;

@Trace
@OnActivityResult(ADD_ACCOUNT)
void onAddedAccount(int result, Intent data) {
}

@Trace
@OnActivityResult(EDIT_ACCOUNT)
void onEditedAccount(int result, Intent data) {
}

Generated code:

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        LoginActivity_.super.onActivityResult(requestCode, resultCode, data);
        switch (requestCode) {
            case  2 :
                LoginActivity_.this.onEditedAccount(resultCode, data);
            case  1 :
                LoginActivity_.this.onAddedAccount(resultCode, data);
        }
    }

As we see, there is no break after 1st case, so request code 2 falls to 1 too:

01-01 19:05:20.539: I/LoginActivity(3090): Entering [void onEditedAccount(int, android.content.Intent) ]
01-01 19:05:20.549: I/LoginActivity(3090): Exiting [void onEditedAccount(int, android.content.Intent) ], duration in ms: 8
01-01 19:05:20.549: I/LoginActivity(3090): Entering [void onAddedAccount(int, android.content.Intent) ]
01-01 19:05:20.559: I/LoginActivity(3090): Exiting [void onAddedAccount(int, android.content.Intent) ], duration in ms: 5

Activity

  1. naixx commented on Jan 1, 2013

    @naixx
    Contributor

    @luxtau, thank you for reporting, but please see #430, #427, #428, #439.

  2. pyricau commented on Feb 27, 2013

    @pyricau
    Contributor

    We really need to release 2.7.1 :)

  3. mathieuboniface commented on Feb 28, 2013

    @mathieuboniface
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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