title: How to schedule text messages in android?
body: <p>I'm trying to schedule text messages in my app. I'm setting the Time thru TimePicker &amp; Date thru DatePicker. But somehow the code won't work. Please tell me where I'm going wrong. T</p>
  
  <p>The Main Code:</p>
  
  <pre><code>    int Hour = Time_Picker.getCurrentHour();
                      int Minute = Time_Picker.getCurrentMinute();
  
                  DatePicker Date_Picker = (DatePicker)findViewById(R.id.datePicker1);
                  int day = Date_Picker.getDayOfMonth();
                   int month = Date_Picker.getMonth() + 1;
                   int year = Date_Picker.getYear();
  
  
                  Intent myIntent = new Intent(ScheduleMessage.this, MyAlarmService.class);
  
                  Bundle bundle = new Bundle();
                           bundle.putCharSequence("Number", Number.getText().toString());
                           bundle.putCharSequence("Message", Message.getText().toString());
                           myIntent.putExtras(bundle);
  
                  pendingIntent = PendingIntent.getService(ScheduleMessage.this, 0, myIntent, 0);
  
  AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);
  
                   Calendar calendar = Calendar.getInstance();
                   calendar.setTimeInMillis(System.currentTimeMillis());
                   //calendar.add(Calendar.SECOND, 10);
                   calendar.set(year, month, day, Hour, Minute);
  
                   alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(), pendingIntent);
  
                           Toast.makeText(ScheduleMessage.this,"Start Alarm with \n" + 
                           "smsNumber = " + Number.getText().toString() + 
                           "\n" + "smsText = " + Message.getText().toString() + "\nScheduled for :"
                           + Hour +" "+Minute,
                             Toast.LENGTH_LONG).show();
  
  
  `
  </code></pre>
  
  <p>and this is the Service:</p>
  
  <pre><code>public class MyAlarmService extends Service {
      String smsNumberToSend, smsTextToSend;
  
       @Override
       public void onCreate() {
        // TODO Auto-generated method stub
  
        Toast.makeText(this, "MyAlarmService.onCreate()", Toast.LENGTH_LONG).show();
       }
  
  
       @Override
       public void onDestroy() {
        // TODO Auto-generated method stub
         super.onDestroy();
         Toast.makeText(this, "MyAlarmService.onDestroy()", Toast.LENGTH_LONG).show();
       }
  
       @Override
       public void onStart(Intent intent, int startId) {
  
           Toast.makeText(this, "MyAlarmService.onStart()", Toast.LENGTH_LONG).show();
        // TODO Auto-generated method stub
        //super.onStart(intent, startId);
  
        Bundle bundle = intent.getExtras();
             smsNumberToSend = (String) bundle.getCharSequence("Number");
             smsTextToSend = (String) bundle.getCharSequence("Message");
  
        Toast.makeText(this, "MyAlarmService.onStart()", Toast.LENGTH_LONG).show();
        Toast.makeText(this,
               "MyAlarmService.onStart() with \n" +
               "smsNumberToSend = " + smsNumberToSend + "\n" +
               "smsTextToSend = " + smsTextToSend,
               Toast.LENGTH_LONG).show();
  
        SmsManager smsManager = SmsManager.getDefault();
        smsManager.sendTextMessage(smsNumberToSend, null, smsTextToSend, null, null);
  
       }
      @Override
      public IBinder onBind(Intent intent) {
          // TODO Auto-generated method stub
          return null;
      }
  
  }
  </code></pre>
  
  <p>Funny thing, when I add the line <code>calendar.set(Calendar.SECOND,10);</code> - everything works fine. But when I use the same approach and set a specific time, nothing happens.</p>
  
  <p>Please help me, I am new to Android.</p>