Android Question B4A Calendar2 broken in Lollipop?

Derek Johnson

Active Member
Licensed User
Longtime User
I've just installed a previously working app using the calendar2 (version: 1.12) library onto a Nexus 7 (2012) tablet with Lollipop. I changed the manifest to include

B4X:
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo")

as recommended.

Unfortunately when I used the call below to get a list of Calendar events, none were returned.

B4X:
        Dim StartDate As String, EndDate As String
        StartDate=DateTime.Add(DateTime.Now,0,0,-1)
        DateTime.DateFormat="dd MMM yyyy"
        DateTime.TimeFormat="HH:mm"
        Log("Start date is " & DateTime.Date(StartDate))
        'Make sure time starts at Midnight
        StartDate=DateTime.DateParse(DateTime.Date(StartDate))
        DateTime.DateFormat="dd MMM yyyy"
        EndDate=DateTime.Add(StartDate,0,0,3)
        Log("End date is " & DateTime.Date(EndDate))
        mycalendarlist = cal.GetListofEventsforCalendarBetweenDates(CalendarNumber,StartDate,EndDate)
        Log("Number of events in Calendar " & mycalendarlist.Size)


This is from the log:

Start date is 04 Dec 2014
End date is 07 Dec 2014
Number of events in Calendar 0

Is this a known issue - am I doing something wrong?

The previous code correctly locates 3 potential calandars.
 

Derek Johnson

Active Member
Licensed User
Longtime User
I have now found what the problem was. When I was searching for the calendar ID with

B4X:
myMap = cal.GetListOfAllCalendars(False)        'get a "Map" of the available calendars

it returned a calendar ID which had read only access as well as one that did have owner access. ( I have multiple Gmail accounts registered on this device). I used the first ID that I encountered that matched the required calendar name and this one did have sufficient permission (apparently) to get the list of events.

I have since modified the search to myMap = cal.GetListOfAllCalendars(True) which returns an ID which does have permission to get the event list.

I'm a bit puzzled though why you would need more than read-only access to get the list of events.
 
Upvote 0
Top