How to return a result (startActivityForResult) from a TabHost Activity?

Posted by pcm2a on Stack Overflow See other posts from Stack Overflow or by pcm2a
Published on 2010-03-23T02:32:26Z Indexed on 2010/03/23 3:21 UTC
Read the original article Hit count: 550

Filed under:

I have 3 classes in my example: Class A, the main activity. Class A calls a startActivityForResult:

Intent intent = new Intent(this, ClassB.class);
startActivityForResult(intent, "STRING");

Class B, this class is a TabActivity:

Intent intent = new Intent(this, ClassC.class);
tabHost.addTab...

Class C, this class is a regular Activity:

Intent intent = this.getIntent();
intent.putExtra("SOMETHING", "EXTRAS");
this.setResult(RESULT_OK, intent);
finish();

onActivityResult is called in Class A, but the resultCode is RESULT_CANCELED instead of RESULT_OK and the returned intent is null. How do I return something from the Activity inside a TabHost?

I realize that the problem is that my Class C is actually running inside of Class B, and Class B is what is returning the RESULT_CANCELED back to Class A. I just don't know a work around yet.

© Stack Overflow or respective owner

Related posts about android