If you get IndexOutOfBoundsException during retrieving of ToDo.DUE property value, check before it has a value.

Wrong :

lngEnd = _SourceContext.getDate(BlackBerryToDo.DUE, 0);

Correct :

if (todo.countValues(BlackBerryToDo.DUE) > 0)
{
lngEnd = todo.getDate(BlackBerryToDo.DUE, 0);
}
This is because if ToDo has no Due date (I mean, selected ‘ None ‘ value), you can take IndexOutOfBoundsException error. Check before it has a value using countValues (…) > 0
I spent lots of time to solve this exception 🙂
—–

ToDo (Task) ile ilgili uygulama geliştirirken ToDo.DUE bilgisini almanız gerekirse eğer, direkt olarak getDate(ToDo.DUE, 0) ile koda başlamayın. Çünkü bu durum IndexOutOfBoundsException hatası oluşturuyor. Bu exception ın çıkma sebebi de ToDo da Due : None seçilmiş olması. Eğer By Date seçilir ve bir tarih belirtlenirse IndexOutOfBoundsException hatası alınmıyor.

Dolayısı ile kodumuzu aşağıdaki hatalı / doğru durumunu göz önüne alarak yazmakta fayda var. Due : None seçili iken alanda değer olmuyor, Due : By Date seçili iken değer oluyor.

Hatalı :

lngEnd = _SourceContext.getDate(BlackBerryToDo.DUE, 0);

Doğru :

if (todo.countValues(BlackBerryToDo.DUE) > 0)
{
lngEnd = todo.getDate(BlackBerryToDo.DUE, 0);
}
Oldukça zamanımı yedi bu sinir Exception hatası 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.