Question

I have an app that queries the google calendar instances and events API in Android 4.x. I've tested this on various devices and it works but for some reason it doesn't work on HTC Sense 3.6 (Android 4.0.3). Can anyone else confirm this or does anyone know what's going on?

Here's the code snippet that works on non-HTC Sense devices:

Cursor instances = Instances.query(
    context.getContentResolver(), 
    new String[]{Instances.EVENT_ID, Instances.BEGIN, Instances.END, Instances.SELF_ATTENDEE_STATUS}, 
    startTime, 
    startTime+lengthInMillis);
.
.
.
long eventId = instances.getLong(instances.getColumnIndex(Instances.EVENT_ID));
Cursor events = context.getContentResolver().query(
    ContentUris.withAppendedId(Events.CONTENT_URI, eventId),
    new String[] {Events._ID, Events.CALENDAR_ID, Events.TITLE, Events.DESCRIPTION, Events.EVENT_LOCATION, Events.ALL_DAY, Events.AVAILABILITY},
    null,
    null, 
    null);
Was it helpful?

Solution

Apparently HTC Sense 3.6 doesn't like the Instances.query() API so I built the URI manually with the following and everything worked.

    Uri.Builder builder = Instances.CONTENT_URI.buildUpon();
    ContentUris.appendId(builder, startTime);
    ContentUris.appendId(builder, startTime+lengthInMillis);
    Cursor instances = context.getContentResolver().query(
            builder.build(), 
            null, 
            null, 
            null, 
            null);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top