私はグーグルカレンダーサービスを作ろうとしています。
これはカレンダーに関する私のコードです。
if(android.os.Build.VERSION.SDK_INT >= 14)
{
LogShow("14");
final String[] COLS = new String[] {
CalendarContract.Events.TITLE,
CalendarContract.Events.DTSTART,
CalendarContract.Events.DTEND,
CalendarContract.Events.EVENT_LOCATION
};
String TtsData = "";
Cursor mCursor = mContext.getContentResolver().query(
CalendarContract.Events.CONTENT_URI, COLS, null, null, null);
if(mCursor.moveToFirst())
{
LogShow("mCursor.moveToFirst()==NULL");
}
Calendar c = Calendar.getInstance();
int day = c.get(Calendar.DAY_OF_MONTH);
int month = c.get(Calendar.MONTH);
int year = c.get(Calendar.YEAR);
int hour = c.get(Calendar.HOUR_OF_DAY);
while(mCursor.moveToNext())
{
LogShow("mCursor.moveToNext()");
String title = mCursor.getString(0);
Date begin = new Date(mCursor.getLong(1));
Date end = new Date(mCursor.getLong(2));
String EventLocation = mCursor.getString(3);
if(begin.getDate() == day && begin.getMonth() == month && begin.getYear()+1900 == year)
{
LogShow("begin.getDate() == day && begin.getMonth() == month && begin.getYear()+1900 == year");
if(hour < begin.getHours())
{
if(!EventLocation.equals(""))
{
if(Value.location.equals(Value.EnglishUK) || Value.location.equals(Value.EnglishUS) || Value.location.equals(Value.Canada))
{
TtsData += " , " + "Title is " + title + ", " + "Start Time" + " , " +
begin.getHours() + ", End Time , " + end.getHours() + ", Event Location , "
+ EventLocation + " , ";
}
else if(Value.location.equals(Value.French) || Value.location.equals(Value.CanadaFrench))
{
TtsData += " , " + "Intitulé " + title + ", " + "Début" + " , " +
begin.getHours() + ", Fin , " + end.getHours() + ", Lieu de rendez-vous , "
+ EventLocation + " , ";
}
else if(Value.location.equals(Value.Germany))
{
TtsData += " , " + "Titel ist " + title + ", " + "Startzeit" + " , " +
begin.getHours() + ", Endzeit , " + end.getHours() + ", Veranstaltungsort , "
+ EventLocation + " , ";
}
else if(Value.location.equals(Value.Italian))
{
TtsData += " , " + "Titolo è " + title + ", " + "Ora d'inizio" + " , " +
begin.getHours() + ", Ora fine , " + end.getHours() + ", Luogo dell'evento , "
+ EventLocation + " , ";
}
}
else
{
if(Value.location.equals(Value.EnglishUK) || Value.location.equals(Value.EnglishUS) ||
Value.location.equals(Value.Canada))
{
TtsData += " , " + "Title is " + title + ", " + "Start Time" + " , " +
begin.getHours() + ", End Time , " + end.getHours();
}
else if(Value.location.equals(Value.French) || Value.location.equals(Value.CanadaFrench))
{
TtsData += " , " + "Intitulé " + title + ", " + "Début" + " , " +
begin.getHours() + ", Fin , " + end.getHours();
}
else if(Value.location.equals(Value.Germany))
{
TtsData += " , " + "Titel ist " + title + ", " + "Startzeit" + " , " +
begin.getHours() + ", Endzeit , " + end.getHours();
}
else if(Value.location.equals(Value.Italian))
{
TtsData += " , " + "Titolo è " + title + ", " + "Ora d'inizio" + " , " +
begin.getHours() + ", Ora fine , " + end.getHours();
}
}
}
}
}
if(TtsData.equals(""))
{
Value.TTS_Data = "You don't have schedule";
new TextToVoice(mContext, TextToVoice.SPEECH);
}
else
{
Value.TTS_Data = TtsData;
new TextToVoice(mContext, TextToVoice.SPEECH);
}
}
}
バージョン API14 以降、Cursor.moveToFirst および Cursor.moveToNext は、カレンダー イベントが既に存在する場合でも NULL を返します。
この問題を解決するにはどうすればよいですか?