Write, Bureaucrats, Administrators
4,332
edits
mNo edit summary |
mNo edit summary |
||
Line 446: | Line 446: | ||
</source> | </source> | ||
==== | ==== Script to insert an appointment into Google Calendar ==== | ||
Suppose a library contains time and name of an appointment. | |||
<source lang="javascript" | |||
i = intent("android.intent.action.INSERT") | <source lang="javascript"> | ||
i.data("content://com.android.calendar/events") | i = intent("android.intent.action.INSERT") // Create Intent object with action Create Appointment | ||
i.extra("title", entry().field("Title")) | i.data("content://com.android.calendar/events") // For INSERT event, data contains Google Calendar URI | ||
i.extra("description" , entry().field("Description")) | i.extra("title", entry().field("Title")) // Get name of event from the field Title | ||
i.extraLong("beginTime" , entry().field("Begin").getTime()) | i.extra("description" , entry().field("Description")) // Get description of event from the field Description | ||
i.extraLong("endTime" , entry().field("End").getTime()) | i.extraLong("beginTime" , entry().field("Begin").getTime()) // Get start time from the field Begin. Begin is of type DateTime. | ||
i.send() | // Additional parameter is of type Long, so extraLong() is used for conversion. | ||
i.extraLong("endTime" , entry().field("End").getTime()) // Get end time from the field End. Requires same conversion as above. | |||
i.send() // Send the message | |||
</source> | </source> | ||
== JavaScript links == | == JavaScript links == | ||
{{Template:JavaScriptLinks}} | {{Template:JavaScriptLinks}} |