title: Android app crashes on starting new activity
body: <p>When I click on a button (called chooseDistance) I simply want to start another activity, this I believe is working, however I have an if statement to check if a value is not null before this activity can start, this I believe is working as when I click the button it does not start the activity if the value is null. I have included the activity in the manifest file. I cannot find the error in my code below:</p>
  
  <p>setdestination.class:</p>
  
  <pre><code>package com.example.drivetext;
  
  import java.util.ArrayList;
  import com.google.android.gms.maps.GoogleMap;
  import com.google.android.gms.maps.GoogleMap.OnMapLongClickListener;
  import com.google.android.gms.maps.MapFragment;
  import com.google.android.gms.maps.model.LatLng;
  import com.google.android.gms.maps.model.MarkerOptions;
  import android.app.Activity;
  import android.app.FragmentManager;
  import android.content.Intent;
  import android.location.Location;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.AdapterView;
  import android.widget.AdapterView.OnItemClickListener;
  import android.widget.ArrayAdapter;
  import android.widget.Button;
  import android.widget.ListView;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class setdestination extends Activity implements OnMapLongClickListener {
  
          private GoogleMap map;          
          Location myLocation;
          TextView tvLocInfo;
          LatLng pointfinal;
          ListView listview;
          ArrayList&lt;String&gt; distancesendList;
          String finaldistance;
          String contactNo;
          String message;
  
          @Override
          protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.setdestination);
              Intent intent = getIntent();
              contactNo = intent.getStringExtra("PhoneNumber");
              message = intent.getStringExtra("TextMessage");
              Toast.makeText(this, contactNo, Toast.LENGTH_LONG).show();
              Toast.makeText(this, message, Toast.LENGTH_LONG).show();                
  
              ListView distanceList=(ListView)findViewById(R.id.list);
  
  
              distancesendList = new ArrayList&lt;String&gt;();
              getdistances();
              // Create The Adapter with passing ArrayList as 3rd parameter
              ArrayAdapter&lt;String&gt; arrayAdapter =      
              new ArrayAdapter&lt;String&gt;(this,android.R.layout.simple_list_item_1, distancesendList);
              // Set The Adapter
              distanceList.setAdapter(arrayAdapter); 
  
              // register onClickListener to handle click events on each item
              distanceList.setOnItemClickListener(new OnItemClickListener()
                 {
                          // argument position gives the index of item which is clicked
                         public void onItemClick(AdapterView&lt;?&gt; arg0, View v,int position, long arg3)
                         {
  
                                 String selecteddistance=distancesendList.get(position);
                                 finaldistance = selecteddistance;
                                 Toast.makeText(getApplicationContext(), "Distance Selected : "+selecteddistance,   Toast.LENGTH_LONG).show();
                              }
                 });
  
              tvLocInfo = (TextView)findViewById(R.id.locinfo);
  
              FragmentManager myFragmentManager = getFragmentManager();
              MapFragment myMapFragment = (MapFragment)myFragmentManager.findFragmentById(R.id.map);
              map = myMapFragment.getMap();
  
              map.setMyLocationEnabled(true);
  
              map.setMapType(GoogleMap.MAP_TYPE_HYBRID);
              //myMap.setMapType(GoogleMap.MAP_TYPE_NORMAL);
              //myMap.setMapType(GoogleMap.MAP_TYPE_SATELLITE);
              //myMap.setMapType(GoogleMap.MAP_TYPE_TERRAIN);
              map.setOnMapLongClickListener(this);
  
              Button chooseDistance = (Button) findViewById(R.id.btnchooseDistance);
                chooseDistance.setOnClickListener(new View.OnClickListener() {              
                   public void onClick(View arg0) {
                       if (finaldistance != null)
                       {
                           Intent intent3 = new Intent(getApplicationContext(), targetdistance.class);
                           intent3.putExtra("PhoneNumber", contactNo);
                           intent3.putExtra("TextMessage", message);
                           intent3.putExtra("Coordinate", pointfinal);
                           intent3.putExtra("SelectedDistance", finaldistance);
                           startActivity(intent3);
                       }
                       }
                });
          }
  
          void getdistances()
          {
              distancesendList.add("100");
              distancesendList.add("250");
              distancesendList.add("500");
              distancesendList.add("1000");
          }
  
          public void onMapLongClick(LatLng point) {
              tvLocInfo.setText("New marker added@" + point.toString());
              map.addMarker(new MarkerOptions().position(point).title(point.toString()));
              pointfinal = point;
              Toast.makeText(this, point.toString(), Toast.LENGTH_LONG).show();
          }
     }
  </code></pre>
  
  <p>my targetdistance.class:</p>
  
  <pre><code>package com.example.drivetext;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.os.Bundle;
  import android.widget.Toast;
  
  public class targetdistance extends Activity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.target);
  
      Intent intent = getIntent();
      String cNumber = intent.getStringExtra("PhoneNumber");
      String txt = intent.getStringExtra("TextMessage");
      String coord = intent.getStringExtra("Coordinate");
      String seldis = intent.getStringExtra("SelectedDistance");
  
      Toast.makeText(this, cNumber, Toast.LENGTH_LONG).show();
      Toast.makeText(this, txt, Toast.LENGTH_LONG).show();
      Toast.makeText(this, coord.toString(), Toast.LENGTH_LONG).show();
      Toast.makeText(this, seldis, Toast.LENGTH_LONG).show();
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Lastly my manifest file:</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.drivetext"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk
      android:minSdkVersion="11"
      android:targetSdkVersion="19" /&gt;
  
  &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
  &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/&gt;
  &lt;uses-permission    android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/&gt;
  &lt;uses-permission android:name="android.permission.READ_CONTACTS"/&gt;
  
  &lt;uses-feature
      android:glEsVersion="0x00020000"
      android:required="true"/&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@drawable/ic_launcher"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" &gt;
      &lt;meta-data android:name="com.google.android.gms.version"
         android:value="@integer/google_play_services_version" /&gt;
      &lt;meta-data
  android:name="com.google.android.maps.v2.API_KEY"
  android:value="AIzaSyCvVY0OSaoe6Y_MfpP2S6HZQpXT5jtUwMQ"/&gt;
      &lt;activity
          android:name="com.example.drivetext.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=".setdestination" android:label="Set Destination"&gt; &lt;/activity&gt;
      &lt;activity android:name=".targetdistance" android:label="Target Distance"&gt;       &lt;/activity&gt;
  &lt;/application&gt;
  &lt;/manifest&gt;
  </code></pre>
  
  <p>target.xml:</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"
      android:orientation="vertical" &gt;
  &lt;/LinearLayout&gt;
  </code></pre>