android.provider.CalendarContract.Events Java Examples

The following examples show how to use android.provider.CalendarContract.Events. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CalendarTracker.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void setRegistered(boolean registered) {
    if (mRegistered == registered) return;
    final ContentResolver cr = mSystemContext.getContentResolver();
    final int userId = mUserContext.getUserId();
    if (mRegistered) {
        if (DEBUG) Log.d(TAG, "unregister content observer u=" + userId);
        cr.unregisterContentObserver(mObserver);
    }
    mRegistered = registered;
    if (DEBUG) Log.d(TAG, "mRegistered = " + registered + " u=" + userId);
    if (mRegistered) {
        if (DEBUG) Log.d(TAG, "register content observer u=" + userId);
        cr.registerContentObserver(Instances.CONTENT_URI, true, mObserver, userId);
        cr.registerContentObserver(Events.CONTENT_URI, true, mObserver, userId);
        cr.registerContentObserver(Calendars.CONTENT_URI, true, mObserver, userId);
    }
}
 
Example #2
Source File: TodoTxtTouch.java    From endpoints-codelab-android with GNU General Public License v3.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private void addToCalendar(List<Task> checkedTasks) {
	Intent intent;
	String calendarTitle = getString(R.string.calendar_title);
	String calendarDescription = "";

	if (checkedTasks.size() == 1) {
		// Set the task as title
		calendarTitle = checkedTasks.get(0).getText();
	} else {
		// Set the tasks as description
		calendarDescription = selectedTasksAsString(checkedTasks);

	}

	intent = new Intent(android.content.Intent.ACTION_EDIT)
			.setType(Constants.ANDROID_EVENT)
			.putExtra(Events.TITLE, calendarTitle)
			.putExtra(Events.DESCRIPTION, calendarDescription);
	startActivity(intent);
}
 
Example #3
Source File: BrewTimerStepFragment.java    From biermacht with Apache License 2.0 5 votes vote down vote up
private void createEvent(String title, String description, int daysFromNow) {
  Calendar start = Calendar.getInstance();
  start.add(Calendar.DATE, daysFromNow);

  long startTime = start.getTimeInMillis();

  ContentValues values = new ContentValues();
  values.put(Events.CALENDAR_ID, getCalendarId());
  values.put(Events.ORGANIZER, "Biermacht");
  values.put(Events.TITLE, title);
  values.put(Events.EVENT_LOCATION, "The Brewery");
  values.put(Events.DESCRIPTION, description);
  values.put(Events.EVENT_COLOR, 0xE6A627);
  values.put(Events.DTSTART, startTime);
  values.put(Events.DTEND, startTime);
  values.put(Events.EVENT_TIMEZONE, "Europe/Berlin");
  values.put(Events.EVENT_END_TIMEZONE, "Europe/Berlin");
  values.put(Events.RRULE, "FREQ=DAILY;COUNT=1;");
  values.put(Events.ACCESS_LEVEL, Events.ACCESS_PUBLIC);
  values.put(Events.SELF_ATTENDEE_STATUS, Events.STATUS_CONFIRMED);
  values.put(Events.ALL_DAY, 1);
  values.put(Events.ORGANIZER, "biermacht brews");
  values.put(Events.GUESTS_CAN_INVITE_OTHERS, 1);
  values.put(Events.GUESTS_CAN_MODIFY, 1);
  values.put(Events.GUESTS_CAN_SEE_GUESTS, 1);
  values.put(Events.AVAILABILITY, Events.AVAILABILITY_BUSY);

  Uri uri = c.getContentResolver().insert(Events.CONTENT_URI, values);
  long eventId = new Long(uri.getLastPathSegment());
}
 
Example #4
Source File: MyCalendarActivity.java    From codeexamples-android with Eclipse Public License 1.0 5 votes vote down vote up
public void onClick(View view) {
	// Intent calIntent = new Intent(Intent.ACTION_INSERT);
	// calIntent.setData(CalendarContract.Events.CONTENT_URI);
	// startActivity(calIntent);

	Intent intent = new Intent(Intent.ACTION_INSERT);
	intent.setType("vnd.android.cursor.item/event");
	intent.putExtra(Events.TITLE, "Learn Android");
	intent.putExtra(Events.EVENT_LOCATION, "Home suit home");
	intent.putExtra(Events.DESCRIPTION, "Download Examples");

	// Setting dates
	GregorianCalendar calDate = new GregorianCalendar(2012, 10, 02);
	intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME,
			calDate.getTimeInMillis());
	intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME,
			calDate.getTimeInMillis());

	// Make it a full day event
	intent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, true);

	// Make it a recurring Event
	intent.putExtra(Events.RRULE,
			"FREQ=WEEKLY;COUNT=11;WKST=SU;BYDAY=TU,TH");

	// Making it private and shown as busy
	intent.putExtra(Events.ACCESS_LEVEL, Events.ACCESS_PRIVATE);
	intent.putExtra(Events.AVAILABILITY, Events.AVAILABILITY_BUSY);

	startActivity(intent);

}