title: Intent isn't working, on clicking on the button2, application crashes
body: <p>I am not able to switch between activities, when I click on the <code>button2</code>, the application crashes down.</p>
  
  <p>MainActivity.Java</p>
  
  <pre><code>&lt;pre&gt;package com.example.againtry;
  
      import java.util.Random;
  
      import android.app.Activity;
      import android.content.Intent;
      import android.os.Bundle;
      import android.view.Menu;
      import android.view.View;
      import android.widget.Button;
      import android.widget.TextView;
  
      public class MainActivity extends Activity {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          // Declare our View Variables and assign them the Views from the layout file
  
          final TextView answerLabel = (TextView) findViewById(R.id.textView1);
          Button getAnswerButton = (Button) findViewById(R.id.button1);
  
          getAnswerButton.setOnClickListener(new View.OnClickListener() {
  
      @Override
      public void onClick(View arg0) {
      // The Button was clicked, so the update the answer label with an answer
  
           String answer = "";
      // Randomly select one of three answers: Yes, No or May be
  
      // Update the label with our dynamic answer
  
      Random randomGenerator = new Random(); // Construct a new Random number Generator
      int randomNumber = randomGenerator.nextInt(3);
      answer = Integer.toString(randomNumber);
      // update the label with our dynamic answer
  
      answerLabel.setText(answer);
      }});
  
          Button btnSimple= (Button) findViewById(R.id.button2);
          btnSimple.setOnClickListener(new View.OnClickListener() {
  
      @Override
      public void onClick(View v) {
  
      // From One Activity to another
      Intent intent = new Intent(MainActivity.this, SendMessageActivity.class);
      startActivity(intent);
  
      }});
      }
  
  
  
      @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;
      }}&lt;/pre&gt;
  </code></pre>
  
  <p>This is my Second Activity</p>
  
  <pre><code>SendMessageActivity.Java
  &lt;pre&gt;package com.example.againtry;
  
      import android.app.Activity;
      import android.os.Bundle;
      import android.telephony.SmsManager;
      import android.view.Menu;
      import android.view.View;
      import android.widget.Button;
      import android.widget.EditText;
      import android.widget.Toast;
  
      public class SendMessageActivity extends Activity {
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.send_message);
  
          final EditText editSMS = (EditText) findViewById(R.id.editText1);
          final EditText editPhoneNum = (EditText) findViewById(R.id.phoneNum);
          Button getSendButton = (Button) findViewById(R.id.button1);
  
  
  
          getSendButton.setOnClickListener(new View.OnClickListener() {
  
      @Override
      public void onClick(View v) {
      String phoneNo = editPhoneNum.getText().toString();
      String sms = editSMS.getText().toString();
  
      try {
      SmsManager smsManager = SmsManager.getDefault();
      smsManager.sendTextMessage(phoneNo, null, sms, null, null);
      Toast.makeText(getApplicationContext(), "SMS Sent!",
      Toast.LENGTH_LONG).show();
      } catch (Exception e) {
      Toast.makeText(getApplicationContext(),
      "SMS faild, please try again later!",
      Toast.LENGTH_LONG).show();
      e.printStackTrace();
      }
  
      }
      });
  
      }
  
  
      @Override
      public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
          getMenuInflater().inflate(R.menu.send_message, menu);
          return true;
      }
      }&lt;/pre&gt;
  
  
  Manifest
      &lt;pre&gt; &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.againtry"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="10"
          android:targetSdkVersion="10" /&gt;
      &lt;uses-permission android:maxSdkVersion="10" android:name="android.permission.READ_CONTACTS"/&gt;
      &lt;uses-permission android:maxSdkVersion="10" android:name="android.permission.SEND_SMS"/&gt;
      &lt;uses-permission android:maxSdkVersion="10" android:name="android.permission.READ_SMS"/&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.againtry.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.againtry.SendMessageActivity"
              android:label="@string/title_activity_send_message" &gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
      &lt;/manifest&gt;&lt;/pre&gt;
  
  activity_main&lt;pre&gt;
  
      &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:gravity="bottom"
      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=".MainActivity" &gt;
  
      &lt;Button
          android:id="@+id/button1"
          style="@android:style/ButtonBar"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignBottom="@+id/textView1"
          android:layout_centerHorizontal="true"
          android:layout_marginBottom="70dp"
          android:text="Enlighten Me!" /&gt;
  
       &lt;TextView
          android:id="@+id/textView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentTop="true"
          android:layout_centerHorizontal="true"
          android:layout_marginTop="177dp"
          android:textSize="32sp" /&gt;
  
         &lt;Button
          android:id="@+id/button2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_above="@+id/button1"
          android:layout_alignLeft="@+id/button1"
          android:layout_marginBottom="44dp"
          android:text="Message" /&gt;
  
      &lt;/RelativeLayout&gt;&lt;/pre&gt;
  
  send_message.xml&lt;pre&gt;
  
      &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=".SendMessageActivity" &gt;
  
      &lt;EditText
          android:id="@+id/editText1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentBottom="true"
          android:layout_alignParentLeft="true"
          android:ems="10"
          android:hint="Enter your message" &gt;
  
          &lt;requestFocus /&gt;
      &lt;/EditText&gt;
  
      &lt;Button
          android:id="@+id/sendButton"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignBaseline="@+id/editText1"
          android:layout_alignBottom="@+id/editText1"
          android:layout_alignParentRight="true"
          android:text="@string/button_send" /&gt;
  
      &lt;TextView
          android:id="@+id/messageView1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/editText1"
          android:layout_alignParentTop="true"
          android:layout_marginTop="77dp"
          android:text="TextView" /&gt;
  
      &lt;EditText
          android:id="@+id/phoneNum"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/messageView1"
          android:layout_alignParentTop="true"
          android:layout_marginTop="18dp"
          android:text="Enter Phone Number" android:inputType="number"/&gt;
      &lt;/RelativeLayout&gt;&lt;/pre&gt;
  </code></pre>