3

There are many question here from people having the exact same problem as I, and I've looked though a million, tried different things for 2-3 hours now, and I still can't get it working.

Child Activity:

Intent resultIntent = new Intent(myColorPicker.this, WidgetConfig.class);
resultIntent.putExtra("key", appwidget_notecolor);
setResult(RESULT_OK, resultIntent);
finish();

Parent Activity:

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
  super.onActivityResult(requestCode, resultCode, data);
  // Toast does not show
  Toast.makeText(getApplicationContext(), "onActivityResult fired", Toast.LENGTH_SHORT).show();

  if (resultCode == RESULT_OK ) {
        // Toast does not show
        Toast.makeText(getApplicationContext(), "Result Recieved", Toast.LENGTH_SHORT).show();
    }
}

I launch child activity from parent activity like this:

Intent myColorPickerIntent = new Intent(WidgetConfig.this, myColorPicker.class);
myColorPickerIntent.putExtra("appwidget_notecolor", appwidget_notecolor);
WidgetConfig.this.startActivity(myColorPickerIntent);
Gene Bo
  • 11,284
  • 8
  • 90
  • 137
Jakob Harteg
  • 9,587
  • 15
  • 56
  • 78

3 Answers3

12

Of course you won't get the result, you're calling startActivity() instead of startActivityForResult().

JoxTraex
  • 13,423
  • 6
  • 32
  • 45
5

You don't seem to be calling startActivityForResult() after creating the Intent.

Yojimbo
  • 23,288
  • 5
  • 44
  • 48
3

Are you pass the intent to startActivityForResult() method?

eltabo
  • 3,749
  • 1
  • 21
  • 33