NullPointerException while trying to startActivityForResult
<p>Edit: the answer is not to call <code>startActivityForResult</code> on the called Activity object, instead invoke it from the caller's context.</p>

<p>This is my code, exception on last line:</p>

<pre><code>107 Intent intent = new Intent(CallingActivity.this, CalledActivity.class);
108 CalledActivity calledActivity = new CalledActivity();
109 calledActivity.startActivityForResult(intent, CALLED_ACTIVITY_CODE);
</code></pre>

<p>Inside CallingActivity:</p>

<pre><code>@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);
    Log.i(SR.tag,"req=" + requestCode + " res=" + resultCode); //Never getting here
}
</code></pre>

<p>Manifest file snippet:</p>

<pre><code>&lt;activity android:name=".ui.CallingActivity"
          android:label="@string/app_name"&gt;
    &lt;intent-filter&gt;
        &lt;action android:name="android.intent.action.MAIN" /&gt;
        &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
    &lt;/intent-filter&gt;
&lt;/activity&gt;
&lt;activity android:name=".ui.CalledActivity"&gt;&lt;/activity&gt;
</code></pre>

<p>Exception:</p>

<pre><code>01-14 11:30:14.850: ERROR/AndroidRuntime(1036): FATAL EXCEPTION: main
01-14 11:30:14.850: ERROR/AndroidRuntime(1036): java.lang.NullPointerException
01-14 11:30:14.850: ERROR/AndroidRuntime(1036):     at android.app.Activity.startActivityForResult(Activity.java:2833)
01-14 11:30:14.850: ERROR/AndroidRuntime(1036):     at com.litvin.app.ui.CallingActivity.onSharedPreferenceChanged(CallingActivity.java:109    )
...
</code></pre>

<p>Whenever I move the HOME and LAUNCHER intent filters into <code>.ui.CalledActivity</code>, it works fine. It starts CalledActivity when I press the icon.</p>

<p>I have looked through many similar answers here, but none worked for me.</p>
