我创建了一个可以在自定义日发送消息的SMS调度程序 对于Eg。如果我将日期设置为25/02/2015(星期三)并选择星期六发送消息,它将在2015年2月28日(星期六)直接发送,但问题是我何时使用
c.set(Calendar.HOUR_OF_DAY, mHour);
c.set(Calendar.MINUTE, mMinutes);
c.set(Calendar.SECOND, 0);
c.set(mYear, mMonth, mDay);
Intent i = new Intent(getApplicationContext(), SMSAlaramService.class);
i.putExtra("com.sarita.scheduler.id", campaign_id);
am = (AlarmManager) getApplicationContext().getSystemService(getApplicationContext().ALARM_SERVICE);
pi = PendingIntent.getService(getApplicationContext(), campaign_id, i, PendingIntent.FLAG_UPDATE_CURRENT);
if(repeat.equals("Custom Days"))
{
Date myDate = c.getTime();
int DayofWeek = myDate.getDay();
String chkDayOfWeek= getMon+""+getTues+""+getWed+""+getThurs+""+getFri+""+getSat+""+getSun;
String WeekChecking = Character.toString(chkDayOfWeek.charAt(DayofWeek - 1));
Log.d("Week Checking:", WeekChecking);
int AddDayCounter = 0;
if(!WeekChecking.equals("1"))
{
//int FindDay = 0;
String begining = "";
for(int z = 0; z< DayofWeek-1;z++)
{
begining += Character.toString(chkDayOfWeek.charAt(z));
}
String xyz = chkDayOfWeek.substring(DayofWeek - 1);
xyz += begining;
Log.d("Actual String:", xyz);
for(int j = 0; j < 7;j++)
{
if(Character.toString(xyz.charAt(j)).equals("1"))
{
break;
}
AddDayCounter++;
}
c.add(Calendar.DATE, AddDayCounter);
//////////Want TO View The Date Which Is Incremented//////////////////////
}
}
am.set(AlarmManager.RTC_WAKEUP, c.getTimeInMillis(),pi);
CustomDays的逻辑很简单我只想在发送时输入0或1,然后找到从设定日期到实际发送日期的距离,并增加距离AddDayCounter
,这样它就会发送到那个日期,但我想查看日期,此方法不会在特定时间准确触发警报意味着在延迟几秒钟后发送10到15秒