Code in onActivityResult() not executed
<p>I've got an android application that I want to open a different activity then my main one after a fresh install.</p>

<p>I tried this using startActivityForResult() and SharedPreferences. Here is my code:</p>

<p>main activity:</p>

<p>public class ONTTMainActivity extends Activity {</p>

<p>static final int REQUEST_CODE = 5;</p>

<pre><code>@Override    
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    SharedPreferences settings = getSharedPreferences("prefs", 0);
    boolean firstRun = settings.getBoolean("firstRun", true);

    if(firstRun){

        startActivityForResult(
            new Intent(this, ONTTSplashActivity.class), REQUEST_CODE);
    }

    setContentView(R.layout.activitymain);

} 
</code></pre>

<p>second activity:</p>

<p>public class ONTTSplashActivity extends Activity {</p>

<p>@Override<br>
    public void onCreate(Bundle savedInstanceState) {</p>

<pre><code>    super.onCreate(savedInstanceState);
    setContentView(R.layout.activityonttsplash);

    final Button btnSkip = (Button) findViewById(R.id.button_skip);
    btnSkip.setOnClickListener(new View.OnClickListener() {
         public void onClick(View v) {

            setResult(RESULT_OK);
            finish();       
         }
     });
}

public void onActivityResult(int requestCode, int resultCode, Intent data) {

    Toast.makeText(ONTTSplashActivity.this, "Toast Reached", Toast.LENGTH_LONG).show();

    if (resultCode == RESULT_OK) {
            SharedPreferences settings = getSharedPreferences("ONTT_prefs", 0);
            SharedPreferences.Editor editor = settings.edit();
            editor.putBoolean("firstRun", false);
            editor.commit();
    }
}
</code></pre>

<p>The problem is that even though the second activity is ended the code in the onActivityResult function is never executed. I tried using a toast to see if it has been reached.</p>

<p>I've seen several similar questions but I've tried every solution but it's not working.</p>
