Learning from DashClock: How to display information about your next calendar appointment

DashClock is lock screen clock widget for Android 4.2+. It is an awesome code example, from which we can learn and take snippets. Do you want to know how to display information about your next calendar appointment ? CalendarExtension is good answer. First of all we can access the data by making use of the CalendarContract content provider. Find next single occurrences of an event in next few hours Format information and that's all It's very important to note that these API works only with Android 4.0+. With this code we are going to query CalendarContract instances long now = getCurrentTimestamp(); Cursor cursor= getContentResolver().query( CalendarContract.Instances.CONTENT_URI.buildUpon() .appendPath(Long.toString(now)) .appendPath(Long.toString(now + DEFAULT_LOOK_AHEAD_HOURS * HOUR_MILLIS)) .build(), EventsQuery.PROJECTION, CalendarContract.Instances.ALL_DAY + "=0 AND " + CalendarContract.Instances.SELF_AT...