I am sending yamar to an activity from a fragment to process an information but when I return the result in the resultCode of the onActivityResult returns me random values, what is this?
this is the code I'm using:
Intent intento = new Intent(getActivity(), SegundoActivity.class);
Bundle manejadordp = new Bundle();
ArrayList<String> Al_DP_Data = new ArrayList<String>();
Al_DP_Data.add("PERAS");
Al_DP_Data.add("MANZANAS");
Al_DP_Data.add("GATOS");
Al_DP_Data.add("PERROS");
manejadordp.putStringArrayList("data", Al_DP_Data);
manejadordp.putString("Titulo", "Titulo que tendra el Activity");
intento.putExtras(manejadordp);
startActivityForResult(intento, CODIGO_SOLICITUD);//CODIGO_SOLICITUD=1
In the second activity:
//obtengo los valores del fragment anterior
Bundle manejadord = getIntent().getExtras();
Data = manejadord.getStringArrayList("data");
Titulo.setText(manejadord.getString("Titulo","Seleccione una opcion")); //Poceso informacion .....
btnCancelar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
InputMethodManager inputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(Buscador.getWindowToken(), 0);
setResult(RESULTADO_CANCEL);//RESULTADO_CANCEL = 0
finish();//finishing activity
}
});
btnAceptar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
InputMethodManager inputMethodManager = (InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.hideSoftInputFromWindow(Buscador.getWindowToken(), 0);
Intent intent = new Intent();
intent.putExtra("Opcion", "PERRO");
setResult(RESULTADO_OK, intent);//RESULTADO_OK=1
finish();//finishing activity
}
});
but as you can see in the following image I am returning another different value in the resultCode to which I set it in the setResult
why is this?