startActivityForResult always receives resultCode 0

1

For some reason, my Activity is always returning resultCode 0 . I have already consulted several forums and I have seen that several people went through this, but none of the solutions I found worked for me.

  

CALLING ACTIVITY:

Intent adicionarTurmaDisciplina = new Intent(that, AdicionaDisciplinaNaTurmaActivity.class);
adicionarTurmaDisciplina.putExtra("turma", turmaDisciplina.getTurma());
that.startActivityForResult(adicionarTurmaDisciplina, REQUISICAO_DISCIPLINAS);
  

SETTING THE RESULT:

public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
    case R.id.menuSalvarTurmaDisciplina:
        boolean salvoComSucesso = salvaDados();
        if(salvoComSucesso){

            if (novaDisciplina) {
                //Abre a activity para matricular alunos
                abreMatriculaAluno(that, turmaDisciplina);
            }else{
                Toast msgSalvoComSucesso = Toast.makeText(that, R.string.alert_salvo_com_sucesso, Toast.LENGTH_LONG);
                msgSalvoComSucesso.show();

            }

            if (getParent() == null) {
                setResult(Activity.RESULT_OK);
            } else {
                getParent().setResult(Activity.RESULT_OK);
            }

            finish();
        }

        return salvoComSucesso;

    case R.id.menuCancelarCadastroTurmaDisciplina:
        finish();
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}
  

RECEIVING THE RESULT:

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUISICAO_DISCIPLINAS) {
        if (resultCode == Activity.RESULT_OK) { //resultCode sempre 0
            carregaSpinnerDisciplina();
        }
    }
}

Before I receive the return of the first Activity, I open another. Only after the other is closed do I work the result in the onActivityResult. I do not know if this is making the mistake, but honestly I do not think so.

Any idea what it might be? Hugs

    
asked by anonymous 02.01.2017 / 14:56

0 answers