views:

43

answers:

1
Intent intent = new Intent(this,AnotherClass.class);
intent.putExtra("Name", "foo");
setResult(RESULT_OK, null);

super.onActivityResult(requestCode, resultCode, data);
    switch (requestCode) {
      case (1): {
        TextView textView = (TextView) findViewById(R.id.TextView01);
        if (resultCode == Activity.RESULT_OK) {
          textView.setText("Data" + data.getStringExtra("Name"));
        }

What am I doing wrong?

+1  A: 

There are some things wrong. You dont set the Intent in the method setResult. Check this out: http://developer.android.com/reference/android/app/Activity.html#setResult(int,%20android.content.Intent)

You should pass the intent, instead of null.

Then remove super from onActivityOnResult. Your not calling onActivityOnResult, but your overriding it.

Then you're switching requestCode. Are you sure that RESULT_OK is 1? Otherwise it won't work. So it is better to use there also the constant RESULT_OK than 1.

Roflcoptr