title: Android: start activity from options menu
body: <p>I am trying to start an activity from an options menu, but my app keeps crashing. The only error that I receive is an ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord,Intent) error in the debug window in Eclipse.</p>
  <p>Below is the the code that I am using at the moment, but keep in mind I have tried multiple options, all of which end in the same misery, at the same piece of code - the startActivity statement (discovered by using breakpoints, since I'm not sure how to see the stack trace in the LogCat window, as described in my previous question <a href="https://stackoverflow.com/questions/11589188/android-eclipse-assistance-with-logcat">Android/Eclipse: assistance with LogCat</a>).</p>
  <pre><code>@Override
  public boolean onCreateOptionsMenu(Menu menu) {
      super.onCreateOptionsMenu(menu);
      getMenuInflater().inflate(R.menu.changescheme, menu);
      menu.findItem(R.id.changeScheme).setIntent(new Intent(this, ColourActivity.class));
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
      super.onOptionsItemSelected(item);
      this.closeOptionsMenu();
      startActivity(item.getIntent());
      return true;
  }
  </code></pre>
  <p>And here is the changescheme.xml file:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;menu xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;&gt;
      &lt;item android:id=&quot;@+id/changeScheme&quot; android:title=&quot;Change Colour Scheme&quot; android:icon=&quot;@android:drawable/ic_menu_edit&quot;&gt;&lt;/item&gt;
  &lt;/menu&gt;
  </code></pre>
  <p>I have also tried using a switch(item.getItemId()) statement in the onOptionsItemSelected block as opposed to the menu.findItem in the onCreateOptionsMenu block, but still no luck.</p>
  <p>I have defined the activity in my Manifest file. I can also start the activity from a regular button, and the first time the app opens on a device, the activity is started immediately after my splash screen, and I have had no problems with either of these methods.</p>
  <p>To me this indicates that there is nothing wrong with the ColourActivity class or its associated layout file, but there is a problem with the implementation from the options menu.</p>
  <p>I have also implemented this same method as shown above (in code) in a different app and had no problems, so I'm am really at a loss here.</p>