这让我绝对疯狂。任何人都可以指出我的错误。当活动结果返回时,intent数据始终为null。
public void btnAddActionOnClick (View v) {
Intent i = new Intent(NFCEditActivity.this, NFCAddActionActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivityForResult(i,1);
return;
}
...
@Override
protected void onActivityResult (int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode,resultCode,data);
if(data==null) { Log.e(LOG_TAG,"Intent bundle extras 'data' is null!"); return ; }
...
}
...
@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
selectedAction = (Action) lv.getItemAtPosition(position);
Intent data = new Intent();
data.putExtra("action", selectedAction.intActionNumber);
data.putExtra("test", "test");
setResult(RESULT_OK, intent);
finish();
return;
}
});
答案 0 :(得分:2)
看起来你发错了意图。不应该是setResult(RESULT_OK, data)
,而不是setResult(RESULT_OK, intent)
?