onActivityResult throws Failure delivering result ResultInfo
<p>That's from the main code:</p>

<pre><code>public void ChangeFlag(View view)
{
        Intent dialogIntent = new Intent(getBaseContext(), dialogPickFlag.class);
        dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivityForResult(dialogIntent, 1);
}


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    Toast.makeText(this, data.getStringExtra("str") , 1500 ).show();

}
</code></pre>

<p>and this is from the activity, that's being called:</p>

<pre><code>public void endResult(String s)
{
Intent intent = new Intent();
intent.putExtra("str", s);
setResult(RESULT_OK,intent);
    finish();
}
</code></pre>

<p>yet strangely it crashes with </p>

<pre><code>java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=0, data=null} to activity {Constructor.rob.com/Constructor.rob.com.constr}: java.lang.NullPointerException
</code></pre>

<p>Obviously only the request code has passes, but why not the response and data?</p>

<p>Any ideas? Thanks!</p>

<p><strong>EDIT:
Changed to toast to "Toast.makeText(this, "aaa" , 1500 ).show();" and noticed that it fires prematurely, then the new activity is created, not when it finishes!</strong></p>
