请帮忙..!
我正在尝试在应用程序中设置多个事件/提醒。为此我编写了以下代码(请参阅下面的代码)我的代码没有错误,代码运行成功但是在我打开日历查看事件时运行我的代码后,我发现没有事件放..!我已经参考了此链接上建议的答案, 但仍然无法正常工作。我设置提醒的代码是
private void addReminder(int statrYear, int startMonth, int startDay, int startHour, int startMinut, String title)
{
long calID = 3;
long startMillis = 0;
long endMillis = 0;
Calendar beginTime = Calendar.getInstance();
// Sets the year, month, day of the month, hour of day, and minute fields.
beginTime.set(statrYear, startMonth, startDay, startHour, startMinut); // set(int year, int month, int day, int hourOfDay, int minute).
startMillis = beginTime.getTimeInMillis();
Calendar endTime = Calendar.getInstance();
endTime.set(statrYear, startMonth, startDay, startHour+1, startMinut);
endMillis = endTime.getTimeInMillis();
ContentResolver cr = getContentResolver();
ContentValues values = new ContentValues();
values.put(Events.DTSTART, startMillis);
values.put(Events.DTEND, endMillis);
values.put(Events.TITLE, "Multiple Event Test");
values.put(Events.DESCRIPTION, "My Calendar Test");
values.put(Events.CALENDAR_ID, calID);
values.put(Events.EVENT_TIMEZONE, "Israel/tel-aviv");
Uri uri = cr.insert(Events.CONTENT_URI, values);
}
我在按钮点击事件上调用了这个方法 3 次(一次设置 3 个提醒)——(请看下面的代码)
multiEventbutton = (Button) findViewById(R.id.multi_event);
multiEventbutton.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View arg0)
{
int statrYear=2013, startMonth=9, startDay=21, startHour=9, startMinut=0;
String strRemindarTitle="Title";
for(int i=0; i<3; i++)
{
strRemindarTitle=strRemindarTitle+""+i+1;
addReminder(statrYear, startMonth, startDay, startHour, startMinut, strRemindarTitle);
startDay++;
Toast.makeText(getApplicationContext(), "Event "+(i+1)+" Date= "+startDay+"/"+startMonth+"/"+statrYear, Toast.LENGTH_LONG).show();
//Toast.makeText(getApplicationContext(), "strReturnData= "+strReturnData, Toast.LENGTH_LONG).show();
}
}
});
请帮忙...!谢谢..!