为什么onActivityResult意图数据为空?

时间:2012-08-09 22:01:06

标签: java android null

这让我绝对疯狂。任何人都可以指出我的错误。当活动结果返回时,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;
    }  
     });  

1 个答案:

答案 0 :(得分:2)

看起来你发错了意图。不应该是setResult(RESULT_OK, data),而不是setResult(RESULT_OK, intent)