startActivity crashes when trying to respond to menu click
<p>I know this has been covered elsewhere, but I'm new to the Android platform and am having a hard time figuring out how to add basic menu options to my first app.</p>

<p>I have an options menu setup using</p>

<pre><code>@Override
public boolean onCreateOptionsMenu(Menu menu){
  MenuInflater inflater = getMenuInflater();
  inflater.inflate(R.menu.menu, menu);
  return true;
}
</code></pre>

<p>and</p>

<pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;menu xmlns:android="http://schemas.android.com/apk/res/android"&gt;
&lt;item android:id="@+id/menuPrefs" android:icon="@android:drawable/ic_menu_preferences" android:title="Settings"&gt;&lt;/item&gt;
&lt;/menu&gt;
</code></pre>

<p>Then within my main java class I have</p>

<pre><code>@Override
public boolean onOptionsItemSelected(MenuItem item){

 if(item.getItemId()==R.id.menuPrefs) {
  showPrefs();
 }
private void showPrefs() {
 Intent i = new Intent(this, Prefs.class);
 startActivity(i);
}
</code></pre>

<p>And then in Prefs.java I have</p>

<pre><code>public class Prefs extends Activity {

     @Override
     protected void onCreate(Bundle savedInstanceState) {
      Toast.makeText(getBaseContext(), "FNORD", Toast.LENGTH_LONG).show();
     }
    }
</code></pre>

<p>Now from this I would expect to see the Toast message "FNORD" when the menu option is pressed, however the application stops unexpectedly.</p>

<p>If I move the toast statement into the showPrefs() function in place of the startActivity call it works.</p>
