2012-05-30 100 views
0

我有一個應用程序,在Android 4.x中查詢谷歌日曆實例和事件API。我已經在各種設備上進行了測試,它的工作原理,但由於某種原因,它不適用於HTC Sense 3.6(Android 4.0.3)。任何人都可以證實這一點,或者是否有人知道發生了什麼?HTC Sense 3.6不顯示日曆事件?

下面的代碼片段,在非的HTC Sense設備的工作原理:

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); 

回答

0

顯然的HTC Sense 3.6不喜歡Instances.query()API,所以我手動建立的URI具有下列一切工作。

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);