2013-10-20 50 views
1

可見我是新android開發日曆是不是在設備上的日曆應用程序

我想創建這應該是訪問無論從我創建應用程序和Android設備的日曆應用的日曆。

首先,我給我的設備信息:

Android版本:18
設備:華碩的Nexus 7

我使用下面

定的代碼創建日曆應用的4.3
API級別
ContentValues values = new ContentValues(); 
    values.put(
    Calendars.ACCOUNT_NAME, "[email protected]"); 
    values.put(
      Calendars.ACCOUNT_TYPE, CalendarContract.ACCOUNT_TYPE_LOCAL); 
    values.put(
      Calendars.NAME, "Test Calendar"); 

    values.put(
      Calendars.CALENDAR_DISPLAY_NAME, "abc calendar"); 
    values.put(
      Calendars.CALENDAR_COLOR, Color.YELLOW); 
    values.put(
      Calendars.CALENDAR_ACCESS_LEVEL, Calendars.CAL_ACCESS_OWNER); 
    values.put(
      Calendars.OWNER_ACCOUNT,"[email protected]"); 
    values.put(
      Calendars.CALENDAR_TIME_ZONE, TimeZone.getDefault().getID()); 
    values.put(Calendars.VISIBLE, 1); 
    Uri.Builder builder = 
      CalendarContract.Calendars.CONTENT_URI.buildUpon(); 
    builder.appendQueryParameter(
      Calendars.ACCOUNT_NAME,"[email protected]"); 
    builder.appendQueryParameter(
      Calendars.ACCOUNT_TYPE, CalendarContract.ACCOUNT_TYPE_LOCAL); 
    builder.appendQueryParameter(
      CalendarContract.CALLER_IS_SYNCADAPTER, "true"); 
    Uri uri =this.cordova.getActivity().getContentResolver().insert(builder.build(), values); 

    try { 
     return calendarArray.put(new JSONObject().put("calendarURI", uri)); 
    } catch (JSONException e) { 
     e.printStackTrace(); 
    } 
    return null; 

當我在應用程序中運行代碼時創建日曆,但之後當我檢查我的設備時,沒有創建新日曆可見然後在這裏。

我曾嘗試像設置值爲1的Calendars.VISIBLE屬性,並在網上搜索解決方案,但什麼都沒有。

的代碼已經從link

複製請幫我在這裏。

回答

1

這是我的錯,日曆在我開始創建應用程序的那一刻開始之前以同樣的名稱添加了9次。