The 1st Activity (EditCycle) calls the 2nd activity (EditChooseLists)
Intent i=new Intent(EditCycle.this,EditChooseLists.class);
startActivityForResult(i, RESULT_OK);
The 2nd activity (EditChooseLists) is ended as such
Toast.makeText(EditChooseLists.this, list.get(position), Toast.LENGTH_SHORT).show();
Intent i=new Intent();
i.putExtra("desc",content);
i.putExtra("content", list.get(position));
setResult(RESULT_OK,i);
finish();
The 1st Activity (EditCycle) has the method onActivityResult overridden as such
@Override
public void onActivityResult(int requestCode,int resultCode,Intent data){
super.onActivityResult(requestCode, resultCode, data);
System.out.print("Test Result !");
String content=data.getExtras().getString("content");
System.out.println("result String"+content);
Toast.makeText(EditCycle.this,content, Toast.LENGTH_SHORT).show();
TextView t=(TextView)findViewById(R.id.tv_editcycle_cropLbl);
t.setText(content);
}
Yet nothing happens when the 2nd activity is resumed, nothing in the console, no toast, textview unchanged
I've concluded that the onActivityResult then is not being called
Can anyone help ?
Your problem is here:
startActivityForResult(i, RESULT_OK);
Because RESULT_OK == -1
and passing a negative value as the second parameter to startActivityForResult
breaks this promise in the method itself (from the Android Developer documentation):
void startActivityForResult (Intent intent, int requestCode)
requestCode
int
: If >= 0, this code will be returned in onActivityResult() when the activity exits.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With