title: After clicking on my listview i want it to extract the phonenumber then send SMS to the clicked phonenumber
body: <p>I am very new to android and do not have much knowledge about java but am required due to school project. I need the phonenumber to be extracted and send SMS when a particular name or number is clicked on the listview. I am stuck. Thanks in advance. Now i only manage to send a SMS to this number "123456" whenever i click any item from the list. This are all my codes.</p>
  
  <p>Contacts</p>
  
  <pre><code>package com.Elson.ProjectVersion;
  
  import java.text.DateFormat;
  import java.util.ArrayList;
  import java.util.Collections;
  import java.util.Date;
  
  
  public class Contacts implements Comparable&lt;Contacts&gt; {
  
      private long id;
      private String name;
      private int Phone;
      private int Email;
      private Date date;
      private double runningAverage;
  
  
  
  
      public Contacts(String name, int Phone,  Date date) {
          this.name = name;
          this.Phone = Phone;
          this.date = null;
      }
  
      public Contacts(long id, String name,int Phone) {
          this.id=id;
          this.Phone=Phone;
          this.name= (name);
  
      }
  
  
      public long getId() {
  
          return id;
      }
      public void setId(long id) {
          this.id = id;
      }
  
      public int getPhone() {
          return Phone;
      }
      public void setPhone(int Phone) {
          this.Phone = Phone;
      }
      public String getname() {
          return name;
      }
      public void setname(String name) {
          this.name = name;
      }
      public Date getDate() {
          return null;
      }
  
      public long getDateEpoch(){
          return date.getTime()/1000;
      }
      public void setDateEpoch(long seconds){
          date= new Date (seconds*1000);
      }
      public void setDate(Date date) {
          this.date = date;
      }
  
  
  
  
      public void setRunningAverage(double runningAverage) {
          this.runningAverage = runningAverage;
      }
      public boolean equals(Object that){
          Contacts bs = (Contacts) that;
  
          return this.date.equals(bs.date);
        }
  
  
      @Override
  
  
  
      public String toString() {
          String result;
  
          if(date != null) {
              DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT);
              result = df.format(date) + "" + name + "" + Phone ; 
      }
      else {
            result = name + "" + Phone ; 
      }
          return result;
      }
  
  
  
  
  
      @Override
      public int compareTo(Contacts another) {    
          // TODO Auto-generated method stub
          return 0;
      }
  
  }
  </code></pre>
  
  <p>SendActivity</p>
  
  <pre><code>package com.Elson.ProjectVersion;
  
  import java.util.ArrayList;
  
  import android.app.AlertDialog;
  import android.app.ListActivity;
  import android.app.PendingIntent;
  import android.content.DialogInterface;
  import android.content.Intent;
  import android.os.Bundle;
  import android.telephony.SmsManager;
  import android.util.Log;
  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;
  
  public class SendActivity extends ListActivity {
  
  Bundle savedInstanceState;
  private ArrayList&lt;Contacts&gt; allContacts;
  private Button AddContactsButton;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      this.savedInstanceState = savedInstanceState;
      setContentView(R.layout.send_layout);
  
  
      // get data from the App
      ContactsActivityApplication app = (ContactsActivityApplication) getApplication();
      allContacts = app.getAllContacts();
  
      // View --- Adapter ------ Data
  
      setListAdapter(new ArrayAdapter&lt;Contacts&gt;(this, R.layout.history_row, R.id.textStart, allContacts));
  
      final ListView listView = this.getListView();
      listView.setOnItemClickListener(new OnItemClickListener() {
  
          @Override
          public void onItemClick(AdapterView&lt;?&gt; parent, View view, int position, long id) {
              Contacts selectedContax = (Contacts) listView.getSelectedItem();
              //sendSMS(String.valueOf("123456"), "Hi");
          }
      }
  
      );
  }
  
  private void sendSMS(String phoneNumber, String message) {
      PendingIntent pi = PendingIntent.getActivity(this, 0, new Intent(this, SendActivity.class), 0);
      SmsManager sms = SmsManager.getDefault();
      sms.sendTextMessage(phoneNumber, null, message, pi, null);
  }
  
  public void AddContactstoListClickHandler (View v){
  
      Intent intent = new Intent(this, EnterContactsActivity.class);
      startActivity(intent);
  }
  
  }
  </code></pre>