I found that Events.CONTENT_EXCEPTION_URI ( here ) is used to create a repeating event. You can hardly find a document or sample code from the Internet. Therefore I try many ways
1 Insert as a sync adapter
ContentValues values = new ContentValues(); values.put(Events.ORIGINAL_INSTANCE_TIME, CaldavGlobalVar.getCurrentTime_()); values.put(Events.SELF_ATTENDEE_STATUS, status); if(!username.equals("")){ values.put(Events.ORGANIZER, username); } if(event.getSummarry()!=null){ values.put(Events.TITLE, event.getSummarry()); } if(event.getDescription()!=null){ values.put(Events.DESCRIPTION, event.getDescription()); } if(event.getDateStart()!=null){ values.put(Events.DTSTART, CaldavGlobalVar.convertTIMEtomilisecond(event.getDateStart(), event.getAllDay())); } Uri exceptionUri = Uri. withAppendedPath(Events.CONTENT_EXCEPTION_URI, String.valueOf(event.getEventId())); Uri syncUri = CalendarProvider.asSyncAdapter(exceptionUri, username,context.getResources().getString(R.string.ACCOUNT_TYPE)); Uri resultUri = context.getContentResolver().insert(syncUri, values);
resultUri returns null, I did not see any exceptions or any relationships, so I dig up the Android source code (from here ) and find out how they use Events.CONTENT_EXCEPTION_URI So, I change
2 Insert in "ContentProviderOperation", for example this , on line 1003
ContentValues values = new ContentValues(); values.put(Events.ORIGINAL_INSTANCE_TIME, CaldavGlobalVar.getCurrentTime_()); values.put(Events.SELF_ATTENDEE_STATUS, 1); values.put(Events.STATUS, Events.STATUS_CONFIRMED); ArrayList<ContentProviderOperation> ops = new ArrayList<ContentProviderOperation>(); Uri exceptionUri = Uri.withAppendedPath(Events.CONTENT_EXCEPTION_URI, String.valueOf(eventId)); ops.add(ContentProviderOperation.newInsert(exceptionUri).withValues(values).build()); mHandler.startBatch(mHandler.getNextToken(), null, CalendarContract.AUTHORITY, ops, 1000);
But it shows the log that it was installed unsuccessfully, I'm so worried about it, maybe Google does not support it completely, I also list the entire content provider in Android, I have no exceptions uri ( Events.CONTENT_EXCEPTION_URI ) - content://com.android.calendar/exception
Exception thrown
java.lang.IllegalArgumentException: Unknown URL content:
Does anyone have any experience? Any help appreciated :)
Yours faithfully
android android-contentprovider caldav android-calendar
Tai tran
source share