title: java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.myfirstapp/com.example.myfirstapp.DisplayMessageActivity}
body: <p>I’m following the android tutorial First App in the link below:
  <a href="https://developer.android.com/training/basics/firstapp/starting-activity.html" rel="nofollow">https://developer.android.com/training/basics/firstapp/starting-activity.html</a>
  The app can be launched in the emulator but the problem is when I click on the button “send, the application crashed with the message “unfortunately, my fist app has stopped”.
  I think I did follow the instructions in the tutorial and can’t figure out where is the problem from.</p>
  
  <p>Logcat send this message:</p>
  
  <pre><code>02-12 16:19:36.031: E/AndroidRuntime(786): java.lang.RuntimeException: 
  Unable to instantiate activity 
  ComponentInfo{com.example.myfirstapp/com.example.myfirstapp.DisplayMessageActivity}:
  java.lang.NullPointerException
  </code></pre>
  
  <p>activity_main.xml</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_weight="1"
      android:layout_width="0dp"
      android:layout_height="wrap_content"
      android:hint="@string/edit_message" /&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>MAinActivity.java</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.View;
  import android.widget.EditText;
  
   public class MainActivity extends Activity {
   public final static String EXTRA_MESSAGE = "com.example.myfirstapp.MESSAGE";
  
  /** Called when the user clicks the Send button */
  public void sendMessage(View view) {
      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);
      // Do something in response to button
  }
  
  
  @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.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  
  }
  </code></pre>
  
  <p>activity_display_message.xml</p>
  
  <pre><code>&lt;RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context=".DisplayMessageActivity" &gt;
  
  &lt;TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/hello_world" /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>DisplayMessageActivity.java</p>
  
  <pre><code>package com.example.myfirstapp;
  
  import android.annotation.SuppressLint;
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Build;
  import android.os.Bundle;
  import android.support.v4.app.NavUtils;
  import android.view.MenuItem;
  import android.widget.TextView;
  
  public class DisplayMessageActivity extends Activity {
  
      Intent intent = getIntent();
      String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
  
  
      @SuppressLint("NewApi")
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          // Get the message from the intent
          Intent intent = getIntent();
          String message = intent.getStringExtra(MainActivity.EXTRA_MESSAGE);
  
          // Create the text view
          TextView textView = new TextView(this);
          textView.setTextSize(40);
          textView.setText(message);
  
          // Set the text view as the activity layout
          setContentView(textView);
  
          // Make sure we're running on Honeycomb or higher to use ActionBar APIs
          if (Build.VERSION.SDK_INT &gt;= Build.VERSION_CODES.HONEYCOMB) {
              // Show the Up button in the action bar.
              getActionBar().setDisplayHomeAsUpEnabled(true);
          }
      }
  
      @Override
      public boolean onOptionsItemSelected(MenuItem item) {
          switch (item.getItemId()) {
          case android.R.id.home:
              NavUtils.navigateUpFromSameTask(this);
              return true;
          }
          return super.onOptionsItemSelected(item);
      }
  }
  </code></pre>
  
  <p>MyFirstApp Manifest</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="8"
          android:targetSdkVersion="18" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &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;activity
          android:name="com.example.myfirstapp.DisplayMessageActivity"
          android:label="@string/title_activity_display_message"
          android:parentActivityName="com.example.myfirstapp.MainActivity" &gt;
          &lt;meta-data
              android:name="android.support.PARENT_ACTIVITY"
              android:value="com.example.myfirstapp.MainActivity" /&gt;
      &lt;/activity&gt;
  
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>Thank you for your help</p>