Make an exception event from the original recurring event?

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://com.android.calendar/exception 

Does anyone have any experience? Any help appreciated :)

Yours faithfully

+3
android android-contentprovider caldav android-calendar
source share
1 answer

A small part of my code:

 ContentValues args = new ContentValues(); args.put(CalendarContract.Events.ORIGINAL_INSTANCE_TIME, originalinstancetime); args.put(CalendarContract.Events.STATUS, status); Uri.Builder eventUriBuilder = CalendarContract.Events.CONTENT_EXCEPTION_URI.buildUpon(); ContentUris.appendId(eventUriBuilder, originalEventID); try { final Uri resultUri = context.getContentResolver().insert(eventUriBuilder.build(), args); int eventID = Integer.parseInt(resultUri.getLastPathSegment()); } catch (Exception e) { } 
+4
source share

All Articles