I have 2 Activity classes and 1 Non-Activity class which calls startActivityForResult() from Context passed in constructor. This is how it looks: FirstActivity -> NonActivity -> SecondActivity -> FirstActivity. In SecondActivity there is ArrayList of custom objects that needs to be passed to FirstActivity as a result. There is a problem. When onActivityResult() is called resultCode is RESULT\_CANCELED, but not RESULT\_OK even if setResult(RESULT\_OK, intent) is called. Here is my code:

**NonActivity**

```
public void showActivity() {
    Intent intent = new Intent(request, ActivityKorak.class);
    intent.putExtra("data", fields);

    request.startActivityForResult(intent, 1);
}

```

**SecondActivity**

```
@Override
public void onBackPressed() {
    super.onBackPressed();

    Intent intent = new Intent();
    intent.putExtra("data", fields);
    setResult(Activity.RESULT_OK, intent);

    finish();
}

```

**FirstActivity**

```
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent){
    super.onActivityResult(requestCode, resultCode, intent);
    if(resultCode != Activity.RESULT_CANCELED){
        if(requestCode == 1) {
            Bundle extras = intent.getExtras();
            ArrayList<CustomInput> fields = (ArrayList<CustomInput>) extras.getSerializable("data");
        }
    }
}

```