List of usage examples for android.provider CalendarContract EXTRA_EVENT_END_TIME
String EXTRA_EVENT_END_TIME
To view the source code for android.provider CalendarContract EXTRA_EVENT_END_TIME.
Click Source Link
From source file:net.gsantner.opoc.util.ShareUtil.java
/** * Start calendar application to add new event, with given details prefilled *///w ww.j a va 2s. c o m public boolean createCalendarAppointment(@Nullable String title, @Nullable String description, @Nullable String location, @Nullable Long... startAndEndTime) { Intent intent = new Intent(Intent.ACTION_INSERT).setData(CalendarContract.Events.CONTENT_URI); if (title != null) { intent.putExtra(CalendarContract.Events.TITLE, title); } if (description != null) { description = description.length() > 800 ? description.substring(0, 800) : description; intent.putExtra(CalendarContract.Events.DESCRIPTION, description); } if (location != null) { intent.putExtra(CalendarContract.Events.EVENT_LOCATION, location); } if (startAndEndTime != null) { if (startAndEndTime.length > 0 && startAndEndTime[0] > 0) { intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startAndEndTime[0]); } if (startAndEndTime.length > 1 && startAndEndTime[1] > 0) { intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, startAndEndTime[1]); } } try { _context.startActivity(intent); return true; } catch (ActivityNotFoundException e) { return false; } }
From source file:com.pgmacdesign.rsrtoolbox.FollowUp.java
public void CreateEvent() { //First run method that calculates all end times //Gets the current time in seconds Calendar mycal = Calendar.getInstance(); //secondsStart = c.get(Calendar.SECOND); GetEndTimes(); //Get the end times //Get Strings from EditTexts occ = follow_up_edit_text_occ_amount.getText().toString(); manager = follow_up_edit_text_manager.getText().toString(); customer_name = follow_up_edit_text_customer_name.getText().toString(); customer_number = follow_up_edit_text_customer_number.getText().toString(); notes = follow_up_edit_text_notes.getText().toString(); String superString = notes + "\nOCC: " + occ + "\nManager Involved: " + manager + "\nCustomer: " + customer_name + "\nCustomer Number: " + customer_number; //Create an intent that will enter data into the calendar Intent calIntent = new Intent(Intent.ACTION_INSERT); calIntent.setType("vnd.android.cursor.item/event"); //Put information in calIntent.putExtra(Events.TITLE, "Follow-up"); calIntent.putExtra(Events.EVENT_LOCATION, sp.getString(settings, "work_address", "Address")); calIntent.putExtra(Events.DESCRIPTION, superString); //Increment the date by X days mycal.add(mycal.DATE, duration);/*from ww w .j av a 2 s .co m*/ //Start and end time long startTime = mycal.getTimeInMillis(); //Convert to milliseconds long endTime = startTime + 900000; //15 minutes //Put the calculated start and end time into the calIntent Intent calIntent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startTime); calIntent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime); //Puts event into calendar startActivity(calIntent); }
From source file:com.appnexus.opensdk.utils.W3CEvent.java
@SuppressLint({ "NewApi", "InlinedApi" }) public Intent getInsertIntent() { Intent i;/*from ww w . j a v a 2s . c o m*/ boolean nativeMethod = (!useMIME && Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH); if (nativeMethod) { i = new Intent(Intent.ACTION_EDIT).setData(CalendarContract.Events.CONTENT_URI); } else { i = new Intent(Intent.ACTION_EDIT).setType("vnd.android.cursor.item/event"); } if (!StringUtil.isEmpty(getDescription())) { if (nativeMethod) { i.putExtra(CalendarContract.Events.TITLE, getDescription()); } else { i.putExtra("title", getDescription()); } } if (!StringUtil.isEmpty(getLocation())) { if (nativeMethod) { i.putExtra(CalendarContract.Events.EVENT_LOCATION, getLocation()); } else { i.putExtra("eventLocation", getLocation()); } } if (!StringUtil.isEmpty(getSummary())) { if (nativeMethod) { i.putExtra(CalendarContract.Events.DESCRIPTION, getSummary()); } else { i.putExtra("description", getSummary()); } } if (!StringUtil.isEmpty(getStart())) { long start = -1; start = millisFromDateString(getStart()); if (start > 0) { if (nativeMethod) { i.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, start); } else { i.putExtra("beginTime", start); } } } if (!StringUtil.isEmpty(getEnd())) { long end = -1; end = millisFromDateString(getEnd()); if (end > 0) { if (nativeMethod) { i.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, end); } else { i.putExtra("endTime", end); } } } if (!StringUtil.isEmpty(getStatus())) { if (nativeMethod) { i.putExtra(CalendarContract.Events.STATUS, getStatus()); } } if (!StringUtil.isEmpty(getTransparency())) { if (nativeMethod) { i.putExtra(CalendarContract.Events.VISIBLE, !getTransparency().equals("opaque")); } } if (!StringUtil.isEmpty(getReminder())) { long time = millisFromDateString(getReminder()); if (time < 0) { if (nativeMethod) { i.putExtra(CalendarContract.Reminders.MINUTES, Math.abs(time / 60000)); } } else if (!StringUtil.isEmpty(getStart())) { if (nativeMethod) { long tstart = millisFromDateString(getStart()); if (tstart > 0) { i.putExtra(CalendarContract.Reminders.MINUTES, Math.abs((tstart - time) / 60000)); } } } } StringBuilder repeatRuleBuilder = new StringBuilder(""); if (getRecurrence() != null) { String freq = getRecurrence().getFrequency(); if (!StringUtil.isEmpty(freq)) { if (W3C_DAILY.equals(freq)) { repeatRuleBuilder.append("FREQ=DAILY;"); } else if (W3C_WEEKLY.equals(freq)) { repeatRuleBuilder.append("FREQ=WEEKLY;"); } else if (W3C_MONTHLY.equals(freq)) { repeatRuleBuilder.append("FREQ=MONTHLY;"); } else if (W3C_YEARLY.equals(freq)) { repeatRuleBuilder.append("FREQ=YEARLY;"); } else { freq = ""; } } else { freq = ""; } if (getRecurrence().getInterval() > 0) { repeatRuleBuilder.append("INTERVAL="); repeatRuleBuilder.append(getRecurrence().getInterval()); repeatRuleBuilder.append(";"); } if (W3C_WEEKLY.equals(freq) && getRecurrence().getDaysInWeek() != null && getRecurrence().getDaysInWeek().length > 0) { repeatRuleBuilder.append("BYDAY="); for (int j : getRecurrence().getDaysInWeek()) { switch (j) { case 0: repeatRuleBuilder.append("SU,"); break; case 1: repeatRuleBuilder.append("MO,"); break; case 2: repeatRuleBuilder.append("TU,"); break; case 3: repeatRuleBuilder.append("WE,"); break; case 4: repeatRuleBuilder.append("TH,"); break; case 5: repeatRuleBuilder.append("FR,"); break; case 6: repeatRuleBuilder.append("SA,"); break; } } repeatRuleBuilder.setCharAt(repeatRuleBuilder.length() - 1, ';'); } if (W3C_MONTHLY.equals(freq) && getRecurrence().getDaysInMonth() != null && getRecurrence().getDaysInMonth().length > 0) { repeatRuleBuilder.append("BYMONTHDAY="); for (int j : getRecurrence().getDaysInMonth()) { repeatRuleBuilder.append(j); repeatRuleBuilder.append(","); } repeatRuleBuilder.setCharAt(repeatRuleBuilder.length() - 1, ';'); } if (W3C_YEARLY.equals(freq) && getRecurrence().getDaysInYear() != null && getRecurrence().getDaysInYear().length > 0) { repeatRuleBuilder.append("BYYEARDAY="); for (int j : getRecurrence().getDaysInYear()) { repeatRuleBuilder.append(j); repeatRuleBuilder.append(","); } repeatRuleBuilder.setCharAt(repeatRuleBuilder.length() - 1, ';'); } if (W3C_YEARLY.equals(freq) && getRecurrence().getMonthsInYear() != null && getRecurrence().getMonthsInYear().length > 0) { repeatRuleBuilder.append("BYMONTH="); for (int j : getRecurrence().getMonthsInYear()) { repeatRuleBuilder.append(j); repeatRuleBuilder.append(","); } repeatRuleBuilder.setCharAt(repeatRuleBuilder.length() - 1, ';'); } if (W3C_MONTHLY.equals(freq) && getRecurrence().getWeeksInMonth() != null && getRecurrence().getWeeksInMonth().length > 0) { repeatRuleBuilder.append("BYWEEKNO="); for (int j : getRecurrence().getWeeksInMonth()) { repeatRuleBuilder.append(j); repeatRuleBuilder.append(","); } repeatRuleBuilder.setCharAt(repeatRuleBuilder.length() - 1, ';'); } if (!StringUtil.isEmpty(getRecurrence().getExpires())) { repeatRuleBuilder.append("UNTIL="); repeatRuleBuilder.append(getRecurrence().getExpires()); repeatRuleBuilder.append(";"); } if (getRecurrence().getExceptionDates() != null && getRecurrence().getExceptionDates().length > 0) { repeatRuleBuilder.append("EXDATE="); for (String s : getRecurrence().getExceptionDates()) { repeatRuleBuilder.append(s); repeatRuleBuilder.append(","); } repeatRuleBuilder.setCharAt(repeatRuleBuilder.length() - 1, ';'); } if (nativeMethod) { i.putExtra(CalendarContract.Events.RRULE, repeatRuleBuilder.toString()); } else { i.putExtra("rrule", repeatRuleBuilder.toString()); } } return i; }
From source file:ai.api.sample.MainActivity.java
public synchronized void createCalendarEvent() { Calendar beginTime = Calendar.getInstance(); beginTime.set(2017, 4, 6, 10, 15);//from w w w .j a va 2s . c om Calendar endTime = Calendar.getInstance(); endTime.set(2017, 4, 6, 10, 30); Intent intent = new Intent(Intent.ACTION_INSERT).setData(CalendarContract.Events.CONTENT_URI) .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, beginTime.getTimeInMillis()) .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getTimeInMillis()) .putExtra(CalendarContract.Events.TITLE, "Reminder") .putExtra(CalendarContract.Events.DESCRIPTION, "Group class") .putExtra(CalendarContract.Events.EVENT_LOCATION, "The gym") .putExtra(CalendarContract.Events.AVAILABILITY, CalendarContract.Events.AVAILABILITY_BUSY) .putExtra(Intent.EXTRA_EMAIL, "15.amangupta@gmail.com"); startActivity(intent); }
From source file:it.gulch.linuxday.android.fragments.EventDetailsFragment.java
@SuppressLint("InlinedApi") private void addToAgenda() { Intent intent = new Intent(Intent.ACTION_EDIT); intent.setType("vnd.android.cursor.item/event"); intent.putExtra(CalendarContract.Events.TITLE, event.getTitle()); intent.putExtra(CalendarContract.Events.EVENT_LOCATION, event.getTrack().getRoom().getName()); String description = event.getEventAbstract(); if (StringUtils.isBlank(description)) { description = event.getDescription(); }//from w w w .ja v a 2 s . c om if (StringUtils.isBlank(description)) { description = StringUtils.EMPTY; } // FIXME // Strip HTML //description = StringUtils.stripEnd(Html.fromHtml(description).toString(), " "); // Add speaker info if available if (personsCount > 0) { String personsSummary = StringUtils.join(event.getPeople(), ", "); description = String.format("%1$s: %2$s\n\n%3$s", getResources().getQuantityString(R.plurals.speakers, personsCount), personsSummary, description); } intent.putExtra(CalendarContract.Events.DESCRIPTION, description); Date time = event.getStartDate(); if (time != null) { intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, time.getTime()); } time = event.getEndDate(); if (time != null) { intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, time.getTime()); } startActivity(intent); }
From source file:spit.matrix2017.Activities.EventDetails.java
private void goToCalendar(Calendar beginTime, Calendar endTime) { mEventID = getLastEventId(getContentResolver()) + 1; Intent intent = new Intent(Intent.ACTION_INSERT).setData(CalendarContract.Events.CONTENT_URI) .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, beginTime.getTimeInMillis()) .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getTimeInMillis()) .putExtra(CalendarContract.Events._ID, mEventID).putExtra(CalendarContract.Events.TITLE, event_name) .putExtra(CalendarContract.Events.DESCRIPTION, "Event at Matrix 17") .putExtra(CalendarContract.Events.EVENT_LOCATION, getIntent().getStringExtra("venue") + ", S.P.I.T.") .putExtra(CalendarContract.Events.AVAILABILITY, CalendarContract.Events.AVAILABILITY_BUSY); visitedCalendar = true;/*w w w.j av a 2 s.c om*/ startActivity(intent); }
From source file:edu.usf.cutr.opentripplanner.android.fragments.DirectionListFragment.java
private void setCalendarItinerary() { // Obtaining of the selected itinerary, along with its relevant parameters int selecItinID = (int) tripList.getSelectedItemId(); Itinerary itinerary = otpBundle.getItineraryList().get(selecItinID); long startTime = Long.parseLong(itinerary.startTime); long endTime = Long.parseLong(itinerary.endTime); String departure = (fromHeader.getText().toString().split(","))[0]; String arrival = (toHeader.getText().toString().split(","))[0]; String tripDescription = departure + " " + arrival; Intent intent = new Intent(Intent.ACTION_INSERT); intent.setData(CalendarContract.Events.CONTENT_URI); intent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startTime); intent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime); intent.putExtra(CalendarContract.Events.TITLE, tripDescription); intent.putExtra(CalendarContract.Events.EVENT_LOCATION, departure); startActivity(intent);//from ww w. j av a 2 s.c o m }
From source file:com.pgmacdesign.rsrtoolbox.InputSchedule.java
public void CreateEvent(String title, String address, String description, DatePicker dp) { //First run method that calculates all end times GetEndTimes();//from w w w.ja v a 2 s . c om //Create an intent that will enter data into the calendar Intent calIntent = new Intent(Intent.ACTION_INSERT); calIntent.setType("vnd.android.cursor.item/event"); //Put information in calIntent.putExtra(Events.TITLE, title); calIntent.putExtra(Events.EVENT_LOCATION, address); calIntent.putExtra(Events.DESCRIPTION, description); //Start and End Timing Calendar startTime = Calendar.getInstance(); Calendar endTime = Calendar.getInstance(); //Format: startTime.set(year, month, day, hourOfDay, minute) startTime.set(dp.getYear(), dp.getMonth(), dp.getDayOfMonth(), daily_hour_start, daily_min_start); endTime.set(dp.getYear(), dp.getMonth(), dp.getDayOfMonth(), daily_hour_end, daily_min_end); //Put the calculated start and end time into the calIntent Intent calIntent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, startTime.getTimeInMillis()); calIntent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, endTime.getTimeInMillis()); //Puts event into calendar startActivity(calIntent); }
From source file:com.albedinsky.android.support.intent.CalendarIntent.java
/** *///from w w w . j a v a 2s .c o m @NonNull @Override @SuppressWarnings("ConstantConditions") protected Intent onBuild() { switch (mType) { case TYPE_VIEW: final Uri.Builder builder = CalendarContract.CONTENT_URI.buildUpon(); builder.appendPath("time"); ContentUris.appendId(builder, mBeginTime); return new Intent(Intent.ACTION_VIEW).setData(builder.build()); case TYPE_INSERT_EVENT: return new Intent(Intent.ACTION_INSERT).setData(CalendarContract.Events.CONTENT_URI) .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, mBeginTime) .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, mEndTime) .putExtra(CalendarContract.Events.TITLE, mTitle) .putExtra(CalendarContract.Events.DESCRIPTION, mDescription) .putExtra(CalendarContract.Events.EVENT_LOCATION, mLocation) .putExtra(CalendarContract.Events.AVAILABILITY, mAvailability); case TYPE_EDIT_EVENT: final Intent intent = new Intent(Intent.ACTION_EDIT); intent.setData(ContentUris.withAppendedId(CalendarContract.Events.CONTENT_URI, mEventId)); if (!TextUtils.isEmpty(mTitle)) { intent.putExtra(CalendarContract.Events.TITLE, mTitle); } return intent; default: return new Intent(Intent.ACTION_VIEW) .setData(ContentUris.withAppendedId(CalendarContract.Events.CONTENT_URI, mEventId)); } }