문제

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);
도움이 되었습니까?

해결책

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);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top