0
我想从第二个活动finish();
后面的第二个活动返回第一个活动的两个字符串值。我尝试使用下面的代码,并没有错误,我也无法获得返回值。无法从之前的活动获取数据
活动A
Intent intent = new Intent(activityA.this, activityB.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivityForResult(intent, 100);
@Override
protected void onActivityResult(int requestCode,
int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.i(TAG, "onActivityResult");
if(resultCode == 100){
Bundle res = data.getExtras();
String contentid = res.getString("contentID");
String contenttype = res.getString("contentType");
Log.i(TAG, "contentid:" +contentid);
Log.i(TAG, "contenttype:" +contenttype);
}
}
活动B
@Override
public void onDestroy(){
super.onDestroy();
helper.close();
Intent intent = new Intent();
intent.putExtra("contentID", contentID);
intent.putExtra("contentType", contentType);
setResult(100, intent);
Log.i(TAG, "SETRESULT.................." +intent);
finish();
}
任何注释或答案将不胜感激。
你得到'Log.i(标签,“SETRESULT ..................”+意图);'登录logcat? – 2013-03-13 03:19:27
是...... SETRESULT .......................意向{(有额外)} – 2013-03-13 03:20:22