android return activity extras returns null
<p>When trying to pass data from one activity to another it works fine in one direction parent>>child. But the return path child>>parent crashes I think with a null pointer exception.
Now I can trap the null easy enough but cant figure out where my passed int is getting lost?</p>

<p>How do you debug this type of problem – any insight etc…</p>

<p>the crash occurs of the line: int binVal = extras.getInt("binVal");</p>

<pre><code>// when leaving the child activity
OnClickListener mReturnListener = new OnClickListener() {
    public void onClick(View v) {
        Intent intent = getIntent();
        intent.putExtra("binVal", (int)binVal);
        setResult(Activity.RESULT_OK, intent);
        finish();
    }
};  



//on return to the parent actvity
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    switch (requestCode) { 
    case SET_BIN_TEMP:
        if (resultCode == RESULT_OK) {           
            Bundle extras = getIntent().getExtras();
            if (extras == null)
                Toast.makeText(PilotActivity.this, "null returned!", Toast.LENGTH_SHORT).show();
            else {
                 int binVal = extras.getInt("binVal");
                 text.setText(Integer.toString(binVal));
             }
        }
        return;
    }
}
</code></pre>
