Good morning,
I have the following situation:
I have 4 screens (Activity), they are: MainActivity, DisiplinaActivity, AssessmentActivity, and Final ResultActivity.
The point is, the data collected from the DisiplinaActivity and EvaluationActivity screens return to the MainActivity and then are sent to the Final ResultActivity.
My question is: how do I send this data via key, value? So far I have this code, where I get the values, but I do not know how to send them to the final screen.
Has anyone caught something like this or can you give me a light?
Thank you
public void proximaTela(View v) {
Intent enviarDados = null;
switch (v.getId()) {
case R.id.btnDisciplina:
enviarDados = new Intent(this, DisciplinaActivity.class);
enviarDados.putExtra("disciplina", disciplina);
startActivityForResult(enviarDados, Constantes.REQUEST_CODE_DADOS_DISCIPLINA);
break;
case R.id.btnAvalicao1:
enviarDados = new Intent(this, AvaliacaoActivity.class);
enviarDados.putExtra("avaliacao1", disciplina);
startActivityForResult(enviarDados, Constantes.REQUEST_CODE_DADOS_AVALIACAO);
break;
case R.id.btnAvalicao2:
enviarDados = new Intent(this, AvaliacaoActivity.class);
enviarDados.putExtra("avaliacao2", disciplina);
startActivityForResult(enviarDados, Constantes.REQUEST_CODE_DADOS_AVALIACAO2);
break;
case R.id.telaResultado:
enviarDados = new Intent(this, ResultadoActivity.class);
break;
default:
Toast.makeText(this, "Problema ao enviar ou receber dados!", Toast.LENGTH_SHORT).show();
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (resultCode == RESULT_OK){
if (requestCode == Constantes.REQUEST_CODE_DADOS_DISCIPLINA){
Bundle params = data.getExtras();
String disciplina = params.getString("nomeDisciplina");
String professor = params.getString("nomeProfessor");
}else if (requestCode == Constantes.REQUEST_CODE_DADOS_AVALIACAO){
Bundle params = data.getExtras();
String avaliacao1 = params.getString("tituloAvl1");
Double nota1 = params.getDouble("notaAvl1");
}else if (requestCode == Constantes.REQUEST_CODE_DADOS_AVALIACAO2){
Bundle params = data.getExtras();
String avalicao2 = params.getString("tituloAvl2");
Double nota2 = params.getDouble("notaAvl2");
}
}
}
Save button from the DisciplineActivity screen
public void btnSave (View v) { Intent intent = new Intent (this, MainActivity.class); intent.putExtra ("className", editNameDiscipline.getText (). toString ()); int.extra ()); startActivity (intent); setResult (RESULT_OK, intent); finish (); }