title: Console error while running the app
body: <p>Console gives me the following error while am running the app. Can anyone please help me know what it means? The app doesn't crash, it keeps running.</p>
  
  <pre><code>[2014-06-01 15:06:30 - ddms] Can't bind to local 8700 for debugger
  [2014-06-01 15:06:57 - ddms] Can't bind to local 8700 for debugger
  [2014-06-01 15:07:00 - ddms] Can't bind to local 8700 for debugger
  [2014-06-01 15:07:01 - ddms] Can't bind to local 8700 for debugger
  [2014-06-01 15:07:02 - ddms] Can't bind to local 8700 for debugger
  [2014-06-01 15:07:03 - ddms] Can't bind to local 8700 for debugger
  [2014-06-01 15:09:17 - ddms] null
  java.lang.NullPointerException
      at com.android.ddmlib.Client.read(Client.java:698)
      at com.android.ddmlib.MonitorThread.processClientActivity(MonitorThread.java:311)
      at com.android.ddmlib.MonitorThread.run(MonitorThread.java:263)
  
  [2014-06-01 15:09:17 - ddms] null
  java.lang.NullPointerException
      at com.android.ddmlib.Client.read(Client.java:698)
      at com.android.ddmlib.MonitorThread.processClientActivity(MonitorThread.java:311)
      at com.android.ddmlib.MonitorThread.run(MonitorThread.java:263)
  
  [2014-06-01 18:18:28 - ddms] Can't bind to local 9451 for debugger
  [2014-06-01 18:18:29 - ddmlib] An established connection was aborted by the software in your host machine
  java.io.IOException: An established connection was aborted by the software in your host machine
      at sun.nio.ch.SocketDispatcher.write0(Native Method)
      at sun.nio.ch.SocketDispatcher.write(Unknown Source)
      at sun.nio.ch.IOUtil.writeFromNativeBuffer(Unknown Source)
      at sun.nio.ch.IOUtil.write(Unknown Source)
      at sun.nio.ch.SocketChannelImpl.write(Unknown Source)
      at com.android.ddmlib.JdwpPacket.writeAndConsume(JdwpPacket.java:213)
      at com.android.ddmlib.Client.sendAndConsume(Client.java:642)
      at com.android.ddmlib.HandleHeap.sendREAQ(HandleHeap.java:348)
      at com.android.ddmlib.Client.requestAllocationStatus(Client.java:488)
      at com.android.ddmlib.DeviceMonitor.createClient(DeviceMonitor.java:835)
      at com.android.ddmlib.DeviceMonitor.openClient(DeviceMonitor.java:803)
      at com.android.ddmlib.DeviceMonitor.deviceClientMonitorLoop(DeviceMonitor.java:621)
      at com.android.ddmlib.DeviceMonitor.access$100(DeviceMonitor.java:44)
      at com.android.ddmlib.DeviceMonitor$3.run(DeviceMonitor.java:580)
  
  [2014-06-01 18:21:51 - ddms] Can't bind to local 9704 for debugger
  [2014-06-02 00:43:26 - ddms] Can't bind to local 10636 for debugger
  </code></pre>
  
  <p>While the code goes like this:</p>
  
  <pre><code>package pk.albab.SMSserver;
  
  import java.io.BufferedReader;
  import java.io.File;
  import java.io.FileOutputStream;
  import java.io.FileReader;
  import java.io.FileWriter;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.io.OutputStreamWriter;
  import java.text.ParseException;
  import java.text.SimpleDateFormat;
  import java.util.Calendar;
  import java.util.Date;
  import java.util.StringTokenizer;
  
  import org.apache.http.HttpResponse;
  import org.apache.http.client.methods.HttpGet;
  import org.apache.http.impl.client.DefaultHttpClient;
  
  import android.annotation.SuppressLint;
  import android.app.Activity;
  import android.app.PendingIntent;
  import android.content.BroadcastReceiver;
  import android.content.Context;
  import android.content.Intent;
  import android.content.IntentFilter;
  import android.graphics.Color;
  import android.os.AsyncTask;
  import android.os.Bundle;
  import android.os.Handler;
  import android.support.v7.app.ActionBarActivity;
  import android.telephony.SmsManager;
  import android.view.View;
  import android.widget.TextView;
  import android.widget.Toast;
  
  
  @SuppressLint({ "CutPasteId", "SimpleDateFormat", "SdCardPath" }) public class MainActivity extends ActionBarActivity {
      /** Called when the activity is first created. */
  
      TextView CurrentTime, AppStartTime, SMSCheckTime, SMSstartTime, RejectedSMS, TotalSent, SMSstatus, SendingMessage;
  
      Handler customHandler = new Handler();
      Handler loop = new Handler();
      Handler HandIn = new Handler();
  
      BroadcastReceiver smsSentReceiver, smsDeliveredReceiver;
      String mphone = "", mmessage ="", mdial = "+92", mFile = "", SendingTime = "", myCheck = "_S_";
      String mcDate = "", mg = "";
  
      PendingIntent piSent;
      PendingIntent piDelivered;
  
      int x = 0;
      String[] mtake, Desc;
      int mrejected = 0;
      long msgCounter = 0;
      static long mMainDelay = 1000;
      Date d1 = null, d2 = null;
  
      static SimpleDateFormat mSDF = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
      String msDate = mSDF.format(new Date());
      String mCounter = "";
      public boolean check = true, MessageAvCheck = true, set = true;
  
      private class DownloadWebPageTask extends AsyncTask&lt;String, Void, String&gt; {
          @Override
          protected String doInBackground(String... urls) {
              String tile = "";
              for (String url : urls) {
                  DefaultHttpClient client = new DefaultHttpClient();
                  HttpGet httpGet = new HttpGet(url);
                  try {
                      HttpResponse execute = client.execute(httpGet);
                      InputStream content = execute.getEntity().getContent();
  
                      BufferedReader buffer = new BufferedReader(
                              new InputStreamReader(content));
                      String h = "";
                      while ((h = buffer.readLine()) != null) {
                          tile += h;
                      }
  
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }
              return tile;
          }
  
          public void onPostExecute (String result) {
                  //SMS Sending Delayer
              if (result.indexOf("#") == -1){MessageAvCheck = false;}
              else if (result.indexOf("#") &gt;= 0)
              {
                  mtake = result.split("#");
                                 final Runnable run = new Runnable() { 
                                 public void run() {
                                     if (x &lt; mtake.length-1)
                                  {
                                     StringTokenizer bits = new StringTokenizer(mtake[x], "$");
                                     String mNumber = bits.nextToken();
                                     mphone = bits.nextToken();
                                     mmessage = bits.nextToken();
                                     mphone = mdial.concat(mphone);
                                     SendingMessage.setText(mmessage);
                                     MessageAvCheck = true;
  
                                     if ((mmessage.length()) &lt;= 160){msgCounter++;}else if ((mmessage.length()) &gt; 160){msgCounter += ((mmessage.length()) / 155);}
                                             //Messages sent per day
                                             mCounter = String.valueOf(msgCounter);
                                          try {
                                                 File write = new File("/sdcard/Albab_SMS_Server/MsgCounter.txt");
                                                 OutputStreamWriter myOutWriter = new OutputStreamWriter(new FileOutputStream(write));
                                                 myOutWriter.append(mCounter);
                                                 myOutWriter.close();                                               
                                             } catch (Exception E) {
                                                 Toast.makeText(getBaseContext(), E.getMessage(),
                                                         Toast.LENGTH_SHORT).show();
                                             }
                                          StringTokenizer dt = new StringTokenizer (msDate, " ");
                                          mFile = dt.nextToken();
                                          SendingTime = dt.nextToken();
                                          mFile = mFile.replace("/", "");
                                          SendingTime = SendingTime.replace(":", "");
                                          SendingTime = mFile.concat(SendingTime);
  
                                          //SMS Sending Time + SMS String itself
                                          try {
                                              FileWriter read = new FileWriter("/sdcard/Send_Db/" + "SMS_" + mFile + ".txt", true);
                                              read.append(mtake[x] + " " + SendingTime + "|");
                                              read.close();
                                              }
                                           catch (IOException e) {
                                              try {
                                                     File write = new File("/sdcard/Send_Db/" + "SMS_" + mFile + ".txt");
                                                     write.createNewFile();
                                                     OutputStreamWriter myOutWriter = new OutputStreamWriter(new FileOutputStream(write));
                                                     myOutWriter.append(mtake[x] + " " + SendingTime + "|");
                                                     myOutWriter.close();
                                                 } catch (Exception E) {
                                                     Toast.makeText(getBaseContext(), E.getMessage(),
                                                             Toast.LENGTH_SHORT).show();
                                                 }
                                           }
                                        //Sends SMS
                                          //SmsManager sms = SmsManager.getDefault();
                                          //sms.sendTextMessage(mphone, null, mmessage, piSent, piDelivered);
  
                                      //Sent Or Rejected Record
                                          try {
                                              FileWriter read = new FileWriter("/sdcard/Send_Db/" + mFile + ".txt", true);
                                              read.append(mNumber + myCheck + SendingTime + "|");
                                              read.close();
                                              }
                                        catch (IOException e) {
                                              try {
                                                  File write = new File("/sdcard/Send_Db/" + mFile + ".txt");
                                                  write.createNewFile();
                                                  OutputStreamWriter myOutWriter = new OutputStreamWriter(new FileOutputStream(write));
                                                  myOutWriter.append(mNumber + myCheck + SendingTime + "|");
                                                  myOutWriter.close();
                                              } catch (Exception E) {
                                                  Toast.makeText(getBaseContext(), E.getMessage(),
                                                          Toast.LENGTH_SHORT).show();
                                              }
                                          }
                                          mg += mNumber + myCheck + SendingTime + "|";
                                          }
                                          else if (x == mtake.length-1)
                                          {
                                              MessageAvCheck = false;
                                              if (mg != null)
                                              {
                                                  String SendPage ="http://albab.pk/albab_edu/digital/androidsms.aspx?GetValue=mashal1&amp;myValue=";
                                                  SendPage = SendPage.concat(mg);
                                                  mg = "";
                                                  //SentSMS task = new SentSMS();
                                                  //task.execute(new String[] {SendPage});
                                                  SMSstatus.setText(SendPage);
                                              }
                                          }
                                     loop.postDelayed(this, 20000);
                                          if (x == mtake.length)
                                          {
                                              loop.removeCallbacks(this);
                                              customHandler.postDelayed(finalizer, 1000);
                                          }
                                     x++;
                                 }
                                 };
                                      if (x == 0){loop.postDelayed(run, 0);}
                  }
          }
      }
  
      public void DelayReset(View view){
          mMainDelay = 1000;
          SMSCheckTime.setText("");
          SMSstatus.setText("");
          SMSstatus.setTextColor(Color.BLACK);
          CurrentTime.setTextColor(Color.BLACK);
          customHandler.postDelayed(finalizer, 0);
      }
  
      private class SentSMS extends AsyncTask&lt;String, Void, String&gt; {
          @Override
          protected String doInBackground(String... urls) {
              String tile = "";
              for (String url : urls) {
                  DefaultHttpClient client = new DefaultHttpClient();
                  HttpGet httpGet = new HttpGet(url);
                  try {
                      HttpResponse execute = client.execute(httpGet);
                      InputStream content = execute.getEntity().getContent();
  
                      BufferedReader buffer = new BufferedReader(
                              new InputStreamReader(content));
                      String h = "";
                      while ((h = buffer.readLine()) != null) {
                          tile += h;
                      }
  
                  } catch (Exception e) {
                      e.printStackTrace();
                  }
              }
              return tile;
          }
  
          public void onPostExecute (String result) {
              SendingMessage.setText(result);
          }
      }
  
          @SuppressLint({ "SdCardPath", "SimpleDateFormat" }) @Override
  
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.fragment_main);
  
          piSent = PendingIntent.getBroadcast(this, 0, new Intent("SMS_SENT"), 0);
          piDelivered = PendingIntent.getBroadcast(this, 0, new Intent("SMS_DELIVERED"), 0);
          CurrentTime = (TextView) findViewById(R.id.CurrentTime);
          AppStartTime = (TextView) findViewById(R.id.AppStartTime);
          SMSCheckTime = (TextView) findViewById(R.id.SMSCheckTime);
          SMSstartTime = (TextView) findViewById(R.id.SMSstartTime);
          RejectedSMS = (TextView) findViewById(R.id.RejectedSMS);
          TotalSent = (TextView) findViewById(R.id.TotalSent);
          SMSstatus = (TextView) findViewById(R.id.SMSstatus);
          SendingMessage = (TextView) findViewById(R.id.SendingMessage);
  
         // TelephonyManager  tm=(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
       //   String IMEINumber=tm.getDeviceId();
          //txt.setText(IMEINumber);
  
          //Starting time File Check or Create
              try {
                  File read = new File("/sdcard/Albab_SMS_Server/StartTime.txt");
                BufferedReader buffer = new BufferedReader(new FileReader(read));
                String s = "";
                while ((s = buffer.readLine()) != null) {mcDate += s;}
                buffer.close();
                  }
            catch (IOException e) {
                  try {
                      File write = new File("/sdcard/Albab_SMS_Server/StartTime.txt");
                      write.createNewFile();
                      OutputStreamWriter myOutWriter = new OutputStreamWriter(new FileOutputStream(write));
                      myOutWriter.append(msDate);
                      myOutWriter.close();
                      mcDate = msDate;
                  } catch (Exception E) {
                      Toast.makeText(getBaseContext(), E.getMessage(),
                              Toast.LENGTH_SHORT).show();
                  }
            }
  
          // Total number of SMS File Check or Create
              try {
                  File read = new File("/sdcard/Albab_SMS_Server/MsgCounter.txt");
                BufferedReader buffer = new BufferedReader(new FileReader(read));
                String s = "";
                while ((s = buffer.readLine()) != null) {mCounter += s;}
                buffer.close();
                msgCounter = Integer.parseInt(mCounter);
                  }
            catch (IOException e) {
                  try {
                      File write = new File("/sdcard/Albab_SMS_Server/MsgCounter.txt");
                      write.createNewFile();
                      OutputStreamWriter myOutWriter = new OutputStreamWriter(new FileOutputStream(write));
                      myOutWriter.append(mCounter = "0");
                      myOutWriter.close();
                  } catch (Exception E) {
                      Toast.makeText(getBaseContext(), E.getMessage(),
                              Toast.LENGTH_SHORT).show();
                  }
            }
          //String conversion to Date
              try {d1 = mSDF.parse(mcDate);} catch (ParseException e) {e.printStackTrace();}
              AppStartTime.setText("App Start Time: " + msDate);
          //Keeps the App Running
              customHandler.postDelayed(finalizer, 0);
          }
  
          private Runnable finalizer = new Runnable()
          {
                  public void run()
                  {                   
                      try {d2 = mSDF.parse(msDate);} catch (ParseException e) {e.printStackTrace();}
                      HandIn.postDelayed(new Runnable(){
                          public void run(){
                              msDate = mSDF.format(new Date());
                              CurrentTime.setText("Current Time: " + msDate);
                              HandIn.postDelayed(this, 1000);
                          }
                      }, 1000);
                      if (d2.getTime() - d1.getTime() &gt;= 1000*60*60*24)
                      {
                          try {
                              File write = new File("/sdcard/Albab_SMS_Server/StartTime.txt");
                              OutputStreamWriter myOutWriter = new OutputStreamWriter(new FileOutputStream(write));
                              myOutWriter.write(msDate);
                              myOutWriter.close();
                              try {d1 = mSDF.parse(msDate);} catch (ParseException e) {e.printStackTrace();}
                              mcDate = msDate;
                              msgCounter = 0;
                              check = true;
                              mCounter = String.valueOf(msgCounter);
                          } catch (Exception E) {
                              Toast.makeText(getBaseContext(), E.getMessage(),
                                      Toast.LENGTH_SHORT).show();
                          }
                      }else
                      {
                          if (msgCounter &gt;= 1611){Toast.makeText(getBaseContext(), "Waiting for Next Instant...", Toast.LENGTH_SHORT).show();check=false;}
                          else{check=true;}
                      }
  
                      if (MessageAvCheck == false)
                      {
                          mMainDelay = (mMainDelay*2);
                          SMSCheckTime.setTextColor(Color.BLUE);CurrentTime.setTextColor(Color.RED);
                          SMSCheckTime.setText("SMS Check Time: " + getDate(d2.getTime()+mMainDelay));
                          SMSstatus.setText("No SMS");
                      }
                      else if (MessageAvCheck == true &amp;&amp; check == true){mMainDelay = 1000; SMSCheckTime.setText(""); CurrentTime.setTextColor(Color.BLACK);}
                      if (mMainDelay &gt;= 600000){mMainDelay = 600000;}
  
                      SMSstartTime.setText("SMS Start Time: " + mcDate);
                      RejectedSMS.setText(String.valueOf("Rejected SMS: " + mrejected));
                      TotalSent.setText("Total SMS Sent Today: " + mCounter);
                      customHandler.postDelayed(this, mMainDelay);
                      if (mrejected &gt;= 20){SMSstatus.setText("SMS Status: 20 or More SMS rejected"); customHandler.removeCallbacks(finalizer);}
                      if (check == true)
                      {
                          x = 0;
                          DownloadWebPageTask task = new DownloadWebPageTask();
                          if (set == true)
                              {task.execute(new String[] {"http://albab.pk/albab_edu/digital/androidsms.aspx?myManName=mashal1&amp;SortOrder="}); set = false;}
                          else if (set == false)
                              {task.execute(new String[] {"http://albab.pk/albab_edu/digital/androidsms.aspx?myManName=mashal1&amp;SortOrder=Desc"}); set = true;}
                          if (MessageAvCheck == true)
                          {customHandler.removeCallbacks(finalizer);}
                      }
                  }
          };
  
      private String getDate(long time) {
          Calendar cal = Calendar.getInstance();
          cal.setTimeInMillis(time);
          String date = mSDF.format(cal.getTime()).toString();
          return date;
      }
  
      public void onResume() {
          super.onResume();
          smsSentReceiver=new BroadcastReceiver() {
              @Override
              public void onReceive(Context arg0, Intent arg1) {
                  switch (getResultCode()) {
                  case Activity.RESULT_OK:
                  {
                      Toast.makeText(getBaseContext(), "SMS has been sent", Toast.LENGTH_SHORT).show();
                      myCheck = "_S_";
                      break;
                  }
                  case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
                  {
                          Toast.makeText(getBaseContext(), "Generic Failure", Toast.LENGTH_SHORT).show();
  
                          if (myCheck == "_S_")
                              myCheck = "_R_";
                          else if (myCheck == "_R_")
                              mrejected++;
  
                      break;
                  }
                  case SmsManager.RESULT_ERROR_NO_SERVICE:
                  {
                      Toast.makeText(getBaseContext(), "No Service", Toast.LENGTH_SHORT).show();
  
                      if (myCheck == "_S_")
                          myCheck = "_R_";
                      else if (myCheck == "_R_")
                          mrejected++;
  
                      break;
                  }
                  case SmsManager.RESULT_ERROR_NULL_PDU:
                  {
                      Toast.makeText(getBaseContext(), "Null PDU", Toast.LENGTH_SHORT).show();
  
                      if (myCheck == "_S_")
                          myCheck = "_R_";
                      else if (myCheck == "_R_")
                          mrejected++;
  
                      break;
                  }
                  case SmsManager.RESULT_ERROR_RADIO_OFF:
                  {
                      Toast.makeText(getBaseContext(), "Radio Off", Toast.LENGTH_SHORT).show();
  
                      if (myCheck == "_S_")
                          myCheck = "_R_";
                      else if (myCheck == "_R_")
                          mrejected++;
  
                      break;
                  }
                  default:
                      break;
                  }
              }
          };
          smsDeliveredReceiver=new BroadcastReceiver() {
              @Override
              public void onReceive(Context arg0, Intent arg1) {
                  // TODO Auto-generated method stub
                  switch(getResultCode()) {
                  case Activity.RESULT_OK:
                      Toast.makeText(getBaseContext(), "SMS Delivered", Toast.LENGTH_SHORT).show();
                      break;
                  case Activity.RESULT_CANCELED:
                      Toast.makeText(getBaseContext(), "SMS not Delivered", Toast.LENGTH_SHORT).show();
                      break;
                  }
              }
          };
          registerReceiver(smsSentReceiver, new IntentFilter("SMS_SENT"));
          registerReceiver(smsDeliveredReceiver, new IntentFilter("SMS_DELIVERED"));
      }
  
      public void onPause() {
          super.onPause();
          unregisterReceiver(smsSentReceiver);
          unregisterReceiver(smsDeliveredReceiver);
      }
  }
  </code></pre>
  
  <p>But again, it does crash if i un-comment the following request:</p>
  
  <pre><code>SentSMS task = new SentSMS();
  task.execute(new String[] {SendPage});
  </code></pre>