public class CalendarIntent extends BaseIntent<CalendarIntent>
BaseIntent builder implementation providing API for building and starting of intents
targeting a calendar related applications.
Whether a started calendar intent should insert a new event or edit the existing one may be
specified via type(int) and supplying one of TYPE_VIEW, TYPE_INSERT_EVENT,
TYPE_EDIT_EVENT, TYPE_VIEW_EVENT.
TYPE_VIEW
Use this type when you want to open only calendar at the current date for preview. If you want to
open calendar at different date, you can specify your desired date via beginTime(long).
TYPE_VIEW_EVENT
Use this type when you want to open an existing calendar event for preview. This type requires an
id of the desired event to be specified via eventId(long) otherwise calendar intent cannot
be build properly and BaseIntent.build(Context) will return null.
TYPE_EDIT_EVENT
Use this type when you want to open an existing calendar event for editing. This type requires an
id of the desired event like described for TYPE_VIEW_EVENT above.
TYPE_INSERT_EVENT
Use this type when you want to create a new calendar event. This type requires a begin time to be
specified via beginTime(long) and an end time via endTime(long). Following data
are relatively optional but for 'good' calendar event should be always set: title(CharSequence),
description(CharSequence), location(CharSequence), availability(int).
| Modifier and Type | Class and Description |
|---|---|
static interface |
CalendarIntent.Availability
Defines an annotation for determining set of allowed flags for
availability(int) method. |
static interface |
CalendarIntent.Type
Defines an annotation for determining set of allowed flags for
type(int) method. |
| Modifier and Type | Field and Description |
|---|---|
static int |
AVAILABILITY_BUSY
Flag to identify BUSY availability for the newly creating calendar event.
|
static int |
AVAILABILITY_FREE
Flag to identify FREE availability for the newly creating calendar event.
|
static int |
AVAILABILITY_TENTATIVE
Flag to identify TENTATIVE availability for the newly creating calendar event.
|
static int |
TYPE_EDIT_EVENT
Flag to identify CalendarIntent as intent to edit existing calendar event.
|
static int |
TYPE_INSERT_EVENT
Flag to identify CalendarIntent as intent to create new calendar event.
|
static int |
TYPE_VIEW
Flag to identify CalendarIntent as intent to open calendar.
|
static int |
TYPE_VIEW_EVENT
Flag to identify CalendarIntent as intent to view existing calendar event.
|
| Constructor and Description |
|---|
CalendarIntent()
Creates a new instance of CalendarIntent.
|
| Modifier and Type | Method and Description |
|---|---|
int |
availability()
Returns the availability flag for the new calendar event.
|
CalendarIntent |
availability(int availability)
Sets an availability flag for the calendar event to be newly created.
|
long |
beginTime()
Returns the begin time for the new calendar event.
|
CalendarIntent |
beginTime(long beginTime)
Sets a begin time for the calendar event to be newly created.
|
CharSequence |
description()
Returns the description for the new calendar event.
|
CalendarIntent |
description(CharSequence description)
Sets a description for the calendar event to be newly created.
|
long |
endTime()
Returns the end time for the new calendar event.
|
CalendarIntent |
endTime(long endTime)
Sets an end time for the calendar event to be newly created.
|
protected void |
ensureCanBuildOrThrow()
Called to ensure that this builder can build its Intent from its current data.
|
long |
eventId()
Returns the id of the event to edit or view within calendar.
|
CalendarIntent |
eventId(long eventId)
Sets an id of the calendar event to be edited or viewed.
|
CharSequence |
location()
Returns the location for the new calendar event.
|
CalendarIntent |
location(CharSequence location)
Sets a location for the calendar event to be newly created.
|
protected Intent |
onBuild(Context context)
Invoked from
BaseIntent.build(Context) after BaseIntent.ensureCanBuildOrThrow() to build intent
specific for this intent builder from the current data. |
long |
time()
Returns the time determining where to open the calendar for view.
|
CalendarIntent |
time(long time)
Sets a time determining where to open the calendar for view.
|
CharSequence |
title()
Returns the title for the new calendar event.
|
CalendarIntent |
title(CharSequence title)
Sets a title for the calendar event to be newly created.
|
int |
type()
Returns the type of the intent that will be created by this intent builder.
|
CalendarIntent |
type(int type)
Sets a type determining whether to create, view or edit an event in the calendar.
|
activityNotFoundMessage, activityNotFoundMessage, build, cannotBuildIntentException, dialogTitle, dialogTitle, enterTransition, enterTransition, exitTransition, exitTransition, isActivityForIntentAvailable, notifyActivityNotFound, onStartWith, startWith, transitionspublic static final int TYPE_VIEW
type(int).public static final int TYPE_INSERT_EVENT
type(int).public static final int TYPE_EDIT_EVENT
type(int).public static final int TYPE_VIEW_EVENT
type(int).public static final int AVAILABILITY_BUSY
CalendarContract.Events#AVAILABILITY_BUSY for additional info.public static final int AVAILABILITY_FREE
CalendarContract.Events#AVAILABILITY_FREE for additional info.public static final int AVAILABILITY_TENTATIVE
CalendarContract.Events#AVAILABILITY_TENTATIVE for additional info.public CalendarIntent()
The begin time will be initially set to the current time and the end time to begin time + 1.
beginTime(long),
endTime(long)public CalendarIntent type(int type)
Default value: TYPE_VIEW
type - One of TYPE_VIEW, TYPE_INSERT_EVENT, TYPE_EDIT_EVENT,
TYPE_VIEW_EVENT.type()public int type()
TYPE_VIEW, TYPE_INSERT_EVENT, TYPE_EDIT_EVENT,
TYPE_VIEW_EVENT.type(int)public CalendarIntent eventId(long eventId)
TYPE_EDIT_EVENT or TYPE_VIEW_EVENT.
Default value: -1
public long eventId()
eventId(long)public CalendarIntent time(long time)
TYPE_VIEW.
Default value: System.currentTimeMillis()
time - The desired time where to open the calendar.time()public long time()
time(long)public CalendarIntent beginTime(long beginTime)
TYPE_INSERT_EVENT or TYPE_VIEW.
Default value: System.currentTimeMillis()
beginTime - The desired begin time for the new event in milliseconds.endTime(long),
type(int),
beginTime()public long beginTime()
beginTime(long),
endTime(long)public CalendarIntent endTime(long endTime)
TYPE_INSERT_EVENT.
Note, that the default end time is set to beginTime() +1.
endTime - The desired end time for the new event in milliseconds.beginTime(long),
type(int),
endTime()public long endTime()
endTime(long),
beginTime(long)public CalendarIntent title(CharSequence title)
TYPE_INSERT_EVENT or TYPE_EDIT_EVENT.title - The desired title text. May be null to clear the current one.title()public CharSequence title()
title(CharSequence)public CalendarIntent description(CharSequence description)
TYPE_INSERT_EVENT.description - The desired description text. May be null to clear the current one.description()public CharSequence description()
description(CharSequence)public CalendarIntent location(CharSequence location)
TYPE_INSERT_EVENT.location - The desired location text. May be null to clear the current one.location()public CharSequence location()
location(CharSequence)public CalendarIntent availability(int availability)
TYPE_INSERT_EVENT.
Default value: AVAILABILITY_BUSY
availability - One of AVAILABILITY_BUSY, AVAILABILITY_FREE or AVAILABILITY_TENTATIVE.availability()public int availability()
Default value: AVAILABILITY_BUSY
AVAILABILITY_BUSY, AVAILABILITY_FREE or
AVAILABILITY_TENTATIVE.availability(int)protected void ensureCanBuildOrThrow()
BaseIntent
If there are some required data missing/not specified, an exception indicating such state
should be thrown. The default exception may be created via BaseIntent.cannotBuildIntentException(String).
ensureCanBuildOrThrow in class BaseIntent<CalendarIntent>protected Intent onBuild(Context context)
BaseIntentBaseIntent.build(Context) after BaseIntent.ensureCanBuildOrThrow() to build intent
specific for this intent builder from the current data.onBuild in class BaseIntent<CalendarIntent>context - Context obtained from the IntentStarter.