onActivityResult() is not called after I run finish in the child activity
<p>I'm attempting to pass data between two activities with startActivityForResult(). Here is my code:</p>

<pre><code>//Within an onOptionsItemSelected method
//..
intent.setClass(this, FileManager.class);
startActivityForResult(intent, 0);
//..
}

protected void onActivityResult(int requestCode, int resultCode, Intent intent){
    Log.w("result Recieved", "request code: " + requestCode + ", result code: " + resultCode);
    super.onActivityResult(requestCode, resultCode, intent);
    if (requestCode == 0 &amp;&amp; resultCode == Activity.RESULT_OK){
        extras = intent.getExtras();
        if(extras != null){
            Log.w("result Recieved", "extras non null\n" + extras.toString());
            root = new File(extras.getString("SelectedDir"));
            fileName = extras.getString("SelectedFile");
            loadFile(root, fileName);
        }
    }
}
</code></pre>

<p>In the FileManager I have:</p>

<pre><code>//..
Intent i = new Intent();
Bundle bundle = new Bundle();
bundle.putString("selectedFile", file.getName());
bundle.putString("selectedDir", file.getPath());
i.putExtras(bundle);
setResult(RESULT_OK, i);
Log.d("Finishing status:", "Finishing");
finish();
//..
</code></pre>

<p>It doesn't receive a result until I re-open the activity at which point FileManager is forced to close. This causes the request and result code to be 0, indicating failure. The FileManager class works by displaying a list of files, when one is selected an alert dialog appears for confirmation and in the listener for yes input I call the method detailed above. How do I make it return a result following the call to finish? </p>

<p>EDIT:</p>

<p>I believe the problem is a listener or something continuing to run after finish is called. I'm not sure what though. I've written a test application that switches between two activities with buttons and it works, I have basically the same code as this project without all the extra methods.</p>

<p>EDIT2:
  I commented out basically everything in the FileManager class and it still doesn't return the result right. So, it must be a problem with the activity that starts it.</p>

<p>EDIT3:
  There error was in some old code I forgot to delete, before the switch case statement I put the FLAG_ACTIVITY_NEW_TASK flag on the intent.</p>
