问题描述
我的A类调用startActivityForResult:A类是tabactivity的
my Class A calls a startActivityForResult: class A is activitygroup in the one tab of tabactivity
Intent intent = new Intent(this, ClassB.class);
startActivityForResult(intent, "STRING");
ClassB的是一个共同的活动,而不是在tabactivity,它是单独
ClassB is a common activity ,not in the tabactivity,it is alone
Intent intent = this.getIntent();
intent.putExtra("SOMETHING", "EXTRAS");
this.setResult(RESULT_OK, intent);
finish();
但在A级的onActivityResult没有收到毛岸英,不excute.if我把CLASSA出tabactivity的,我的应用程序就可以了。我读
but in Class A onactivityResult not receive anying,not excute.if i put classA out of the tabactivity,my app is ok. i have read
How到的setResult()为其中包含标签活动
How从TabHost活动返回结果(startActivityForResult)?
但不解决我的问题,有人可以在给一些建议,code是越多越好,谢谢
but not solve my problem,can somebody an give some advice ,code is more better,thank you
编辑:
A类我补充一下:
edit:in class A i add:
public class UpdateImageBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.i("temp","34353");
}
}
/* (non-Javadoc)
* @see android.app.Activity#onPause()
*/
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
unregisterReceiver(updateImageBroadcastReceiver);
}
/* (non-Javadoc)
* @see android.app.Activity#onResume()
*/
@Override
protected void onResume() {
// TODO Auto-generated method stub
super.onResume();
updateImageFilter = new IntentFilter("ACTION_CHANGE_TAB");
updateImageBroadcastReceiver = new UpdateImageBroadcastReceiver();
registerReceiver(updateImageBroadcastReceiver, updateImageFilter);
}
在B类:
Intent intent = new Intent("ACTION_CHANGE_TAB");
intent.putExtra("path", f.getAbsolutePath());
sendBroadcast(intent);
// FileListSelectActivity.this.setResult(RESULT_OK, intent);
finish();
但我不能打印:Log.i(温度,34353);
but i cannot print: Log.i("temp","34353");
推荐答案
尝试使用广播接收机。您可以在活动B覆盖的onStop(),从广播活动B的事件和活动一听。
Try using broadcast receivers. You can override onStop() in activity B, broadcast an event from activity B and listen in activity A.
这篇关于如何从一个活动到TabHost活动返回一个结果(startActivityForResult)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!