title: My First android app crashing and clicking a button
body: <p>I am learning android from official android website. It was wokring fine before when I used to eneter data in text box and click on a button aand the data used to get printed in a different screen. </p>
  
  <p>But after I tried to customize the code, to add menu options. The functionality is no longer working. When I click on the button , the app crashes now. Can anyone advise where I am going wrong?</p>
  
  <p>My MainActivity.java file is as below.</p>
  
  <pre><code>package com.example.myfirstapp;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuInflater;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.EditText;
  
  public class MainActivity extends Activity {
  
      public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
      }
  
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
          // Inflate the menu; this adds items to the action bar if it is present.
          MenuInflater inflater = getMenuInflater();  
          inflater.inflate(R.menu.main_activity_actions, menu);  
          return super.onCreateOptionsMenu(menu); 
      }
  
      /** Called when the user clicks the Send button */
      public void sendMessage(View view) {    
          // Do something in response to button 
          Intent intent = new Intent(this, DisplayMessageActivity.class);
          EditText editText = (EditText) findViewById(R.id.edit_message); 
          String message = editText.getText().toString();
          intent.putExtra(EXTRA_MESSAGE, message);
          startActivity(intent);
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          // Handle presses on the action bar items
          switch (item.getItemId()) {
              case R.id.action_search:
                  openSearch(); 
                  return true;
              case R.id.action_settings:
                  openSettings();
                  return true; 
              default: 
                  return super.onOptionsItemSelected(item); 
          }
      }
  
      private void openSettings() {
          // Later
      }
      private void openSearch() {
          // Later
     }
  }
  </code></pre>
  
  <p>When I am trying to run the application on a tab , I am getting the following error </p>
  
  <pre><code>09-12 14:57:58.702: D/libEGL(5349): loaded /system/lib/egl/libGLES_android.so
  09-12 14:57:58.712: D/libEGL(5349): loaded /system/lib/egl/libEGL_tegra.so
  09-12 14:57:58.722: D/libEGL(5349): loaded /system/lib/egl/libGLESv1_CM_tegra.so
  09-12 14:57:58.732: D/libEGL(5349): loaded /system/lib/egl/libGLESv2_tegra.so
  09-12 14:57:58.782: D/OpenGLRenderer(5349): Enabling debug mode 0
  09-12 14:58:07.662: D/AndroidRuntime(5349): Shutting down VM
  09-12 14:58:07.662: W/dalvikvm(5349): threadid=1: thread exiting with uncaught exception (group=0x40a3e1f8)
  09-12 14:58:07.672: E/AndroidRuntime(5349): FATAL EXCEPTION: main
  09-12 14:58:07.672: E/AndroidRuntime(5349): java.lang.IllegalStateException: Could not execute method of the activity
  09-12 14:58:07.672: E/AndroidRuntime(5349):     at android.view.View$1.onClick(View.java:3044)
  09-12 14:58:07.672: E/AndroidRuntime(5349):     at android.view.View.performClick(View.java:3511)
  09-12 14:58:07.672: E/AndroidRuntime(5349):     at android.view.View$PerformClick.run(View.java:14105)
  09-12 14:58:07.672: E/AndroidRuntime(5349):     at android.os.Handler.handleCallback(Handler.java:605)
  09-12 14:58:07.672: E/AndroidRuntime(5349):     at android.os.Handler.dispatchMessage(Handler.java:92)
  09-12 14:58:07.672: E/AndroidRuntime(5349):     at android.os.Looper.loop(Looper.java:137)
  09-12 14:58:07.672: E/AndroidRuntime(5349):     at android.app.ActivityThread.main(ActivityThread.java:4446)
  09-12 14:58:07.672: E/AndroidRuntime(5349):     at java.lang.reflect.Method.invokeNative(Native Method)
  09-12 14:58:07.672: E/AndroidRuntime(5349):     at java.lang.reflect.Method.invoke(Method.java:511)
  09-12 14:58:07.672: E/AndroidRuntime(5349):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
  09-12 14:58:07.672: E/AndroidRuntime(5349):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
  09-12 14:58:07.672: E/AndroidRuntime(5349):     at dalvik.system.NativeStart.main(Native Method)
  09-12 14:58:07.672: E/AndroidRuntime(5349): Caused by: java.lang.reflect.InvocationTargetException
  09-12 14:58:07.672: E/AndroidRuntime(5349):     at java.lang.reflect.Method.invokeNative(Native Method)
  09-12 14:58:07.672: E/AndroidRuntime(5349):     at java.lang.reflect.Method.invoke(Method.java:511)
  09-12 14:58:07.672: E/AndroidRuntime(5349):     at android.view.View$1.onClick(View.java:3039)
  09-12 14:58:07.672: E/AndroidRuntime(5349):     ... 11 more
  09-12 14:58:07.672: E/AndroidRuntime(5349): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.myfirstapp/com.example.myfirstapp.DisplayMessageActivity}; have you declared this activity in your AndroidManifest.xml?
  09-12 14:58:07.672: E/AndroidRuntime(5349):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1508)
  09-12 14:58:07.672: E/AndroidRuntime(5349):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
  09-12 14:58:07.672: E/AndroidRuntime(5349):     at android.app.Activity.startActivityForResult(Activity.java:3190)
  09-12 14:58:07.672: E/AndroidRuntime(5349):     at android.app.Activity.startActivity(Activity.java:3297)
  09-12 14:58:07.672: E/AndroidRuntime(5349):     at com.example.myfirstapp.MainActivity.sendMessage(MainActivity.java:38)
  09-12 14:58:07.672: E/AndroidRuntime(5349):     ... 14 more
  09-12 15:03:07.712: I/Process(5349): Sending signal. PID: 5349 SIG: 9
  </code></pre>
  
  <p><code>activity_main.xml</code></p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="horizontal"&gt; 
  
      &lt;EditText android:id="@+id/edit_message" 
            android:layout_width="0dp"  
            android:layout_height="wrap_content"  
            android:hint="@string/edit_message" 
            android:layout_weight="1"/&gt;
  
      &lt;Button 
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/button_send"
          android:onClick="sendMessage" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><code>AndroidManifest.xml</code></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.myfirstapp"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="11"
          android:targetSdkVersion="17" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:debuggable="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@android:style/Theme.Holo" &gt;
          &lt;activity
              android:name="com.example.myfirstapp.MainActivity"
              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;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>