title: How to open a second activity on click of button in android app
body: <p>I am learning to build android applications and I need some specific help. I can't seem to get my head around which bits of template code I am required to change, and which bits are static.</p>
  
  <p>In the <strong>LAYOUT</strong> folder I have my <strong>ACTIVITY_MAIN.XML</strong> which reads</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
   &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;Button
      android:id="@+id/button1"
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:text="@string/main_buttons_photos" /&gt;
  
   &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>Next, I have my second activity <strong>ACTIVITY_SEND_PHOTOS.XML</strong> which is</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" &gt;
  
   &lt;TextView
      android:id="@+id/textView2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true"
      android:text="@string/hello_world"
      tools:context=".SendPhotos" /&gt;
  
   &lt;TextView
      android:id="@+id/textView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true"
      android:text="@string/title_activity_send_photos"
      android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
  
   &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>I then have my <strong>MainActivity.java</strong> (is this the .class?) this reads
       package com.example.assent.bc;</p>
  
  <pre><code> import android.os.Bundle;
   import android.app.Activity;
   import android.view.Menu;
   import android.view.View;
  
   public class MainActivity extends Activity {
  
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       setContentView(R.layout.activity_main);
   }
  
   @Override
   public boolean onCreateOptionsMenu(Menu menu) {
       getMenuInflater().inflate(R.menu.activity_main, menu);
       return true;
   }
   /** Called when the user clicks the Send button */
   public void sendMessage(View view) {
       // Do something in response to button
   }
   }
  </code></pre>
  
  <p>and then my <strong>SendPhotos.java</strong> file which is;</p>
  
  <pre><code> package com.example.assent.bc;
  
   import android.os.Bundle;
   import android.app.Activity;
   import android.view.Menu;
   import android.view.MenuItem;
   import android.support.v4.app.NavUtils;
  
   public class SendPhotos extends Activity {
  
   @Override
   public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_send_photos);
      getActionBar().setDisplayHomeAsUpEnabled(true);
   }
  
   @Override
   public boolean onCreateOptionsMenu(Menu menu) {
      getMenuInflater().inflate(R.menu.activity_send_photos, menu);
      return 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>I would like the button in my main activity to link through to my sendphotos activity, simply opening up that activity, nothing fancy, not sending any data or anything.</p>
  
  <p>I know that somewhere I need my </p>
  
  <pre><code> Intent i = new Intent(FromActivity.this, ToActivity.class);
   startActivity(i);
  </code></pre>
  
  <p>but I have no idea what to replace <strong>ToActivity.class</strong> with or what else I need where.</p>