title: intent not working
body: <p>I am learning the concept of <code>Intent</code>s and the application I am working on crashes when i try to go from one intent to another,the intent object is fired on <code>onClickListener()</code> of a button.</p>
  
  <p>Below is the code:</p>
  
  <p><code>intentdemo.java</code>: first activity</p>
  
  <pre><code>import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  
  
  public class intentdemo extends Activity {
      /** Called when the activity is first created. */
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
  
  
          Button btn1= (Button) findViewById(R.id.button1);
          btn1.setOnClickListener(new OnClickListener() {
  
              public void onClick(View v) {
  
                  Intent i = new Intent(intentdemo.this,Intentdemo2.class);
                  startActivity(i);
              }
  
         });
  
  
  
  
      }
  }
  </code></pre>
  
  <p><code>Intentdemo2.java</code>: Activity 2</p>
  
  <pre><code>package com.test.intent;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  
  public class Intentdemo2 extends Activity {
      @Override
  
      public void onCreate(Bundle savedInstanceState)
      {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          Button btn = (Button)findViewById(R.id.button2);
          btn.setOnClickListener(new OnClickListener() {
  
              public void onClick(View v) {
                  // TODO Auto-generated method stub
                  Intent i = new Intent(getBaseContext(),intentdemo.class);
                  startActivity(i);
              }
          });
  
      }
  
  }
  </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.test.intent"
    android:versionCode="1"
    android:versionName="1.0"&gt;
  
  
  &lt;application android:icon="@drawable/icon" android:label="@string/app_name"&gt;
      &lt;activity android:name=".intentdemo"
                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=".Intentdemo2"&gt;&lt;/activity&gt;
  &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>main.xml: for first activity</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      &gt;
  &lt;TextView  
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:text="@string/hello"
      /&gt;
  &lt;Button 
      android:text="Button" 
      android:id="@+id/button1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"&gt;
      &lt;/Button&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>layout.xml: for second activity</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"&gt;
      &lt;Button android:id="@+id/button2" android:layout_height="wrap_content" android:text="Button" android:layout_width="wrap_content"&gt;&lt;/Button&gt;
      &lt;TextView 
      android:text="@string/text" 
      android:id="@+id/textView1" 
  
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content"&gt;&lt;/TextView&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>I would appreciate if someone can point me towards my mistake here, first Activity is displayed, When i click on button it gives me the message "the activity has stopped unexpectedly", how should I debug in case the error in activity is not intuitive.</p>
  
  <p>Thanks,
  Sid</p>