我正在使用SomeActivity扩展TabActivity编写选项卡。 这是主要过程: 主要活动将调用SomeActivity。 SomeActivity会将两个活动(activityone和activitytwo)放到两个标签中。 这是我的问题,当SomeActivity的子活动完成后,我怎么能将一些额外的意图传递给主要活动?
以下是SomeActivity的主要代码,它将由MainActivity调用。
public class SomeActivity extends TabActivity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setResult(Activity.RESULT_OK);
Resources res = getResources(); // Resource object to get Drawables
TabHost tabHost = getTabHost(); // The activity TabHost
TabSpec spec;
Intent intent; // Reusable Intent for each tab
//TAB1
intent = new Intent(this,ActivityOne.class);
spec = tabHost.newTabSpec("tab1")
.setIndicator("Tab1", res.getDrawable(android.R.drawable.ic_media_play))
.setContent(intent);//
tabHost.addTab(spec);//
//TAB2
intent = new Intent(this,ActivityTwo.class);
spec = tabHost.newTabSpec("tab2")
.setIndicator("Tab1", res.getDrawable(android.R.drawable.ic_media_play))
.setContent(intent);//
tabHost.addTab(spec);//
tabHost.setCurrentTab(0);
}
这是我想向MainActivity发送意图的地方。
public class ActivityOne extends Activity{
private void SendIntent()
{
Intent intent = new Intent();
intent.putExtra("information", "someinformation");
// Set result and finish this Activity
setResult(Activity.RESULT_OK, intent);
finish();
}
}