This article focuses on the use of undocumented API to work with standard calendar Android.
For what?!
I ran into this problem when he wrote an application to form an university schedule. It is convenient to have their schedules separately, so even a standard calendar does not support repeating events in one week, which is necessary for a two-week (Thu / odd.) Schedule. Idée fixe was a function of the application, which will "fill" introduced by the schedule Android calendar. Pluses are obvious: Sync with Google Calendar from google (pardon the tautology), built-in calendar widget (very much good this widget from HTC Sense) and a mountain of widgets from third-party manufacturers, which show at least the next event, though utilization of the week, etc.
Use an undocumented API - this is BAD! Got it?Does that solve the problem of the obvious need to use an undocumented API? The answer - no. The proper method is to use the API Google Calendar, I advise you andmake my own applications.
But the "right" method imposes several limitations:
• Do not use the lack of connection to the Internet;
• the need to synchronize the calendar after filling;
• Data (and there are not enough in filling the whole year) go to the server and then goback in sync, which obviously increases the traffic in half.
In my opinion, is much more convenient to use the offline version of the calendar, whichat any opportunity, you can synchronize with guglokalendarem. Unfortunately google did not care about developers for Android and has not published an official API, but to our delight Android source code open and intelligent people have long found the magic URIcontent providers.
We ask the user for permission to work with calendar
Paradox. API does not have, and resolution of the documentation is. You just have toadd them to vashAndroidManifest.xml.
To use the calendar, Android, we must turn to its content provider for a particular URI.Much to our chagrin that the URI is different in different versions of operating systems andis likely to change in the next (the costs of undocumented API). But the problem is solved.
For Froyo [2.2] and is likely for the following versions-content: / / com.android.calendar / calendars.
For versions <2.2 - content: / / calendar / calendars.
As you can see, it's not so bad. You can determine the version of the system and use the appropriate URI, but I went the other way. I watch if there's a URI for <2.2 and if there is no one, then use the remainder.We assume that the URI received.
Get the list of calendars
For users of Google Calendar do not have to explain, and explain to the rest. Public Access consists of one or several small calendars, which can vary in color markers. This is usually something like "personal", "work", "training", etc. Establish such calendars canonly visit guglokalendarya, in the android that standard means you can do.
To add an event, we need to know the ID of the calendar. To perform this task, use the construction of the preceding paragraph.Now the resulting set of names can be displayed in the interface and allow the user to choose.
Add event
Then work with the calendar is, as with any other content provider. This can be read in the documentation.Let's talk about the fields of the event. The description field, I advise you to use to indicateevents. Use this field can then be removed en masse all the events generated by your program. Field names, descriptions and venue are string. We should also mention thetime field. These fields have type long, but these fields can be generated, for example,the following function.With her, I think, will understand themselves, let me note only that it responds to thecurrent time zone.
Remove Event
To delete a message by ID to add it to the URI.To remove the other fields you can get all mouse events, like we did with the calendars, and then selectively remove the ID.
Finally
In conclusion, I remind you that you're using it at your own risk. During development, Ionce wrote a URI is not and my phone every time you sync started to issue an error (corrected erasure of information from the calendar altogether.)
Another trouble - the emulator is no calendar, for it to repeat all the above fails.
And it concluded. I can not take the opportunity popiarit the application, which was discussed in the article. You can find it in the market under the name uTimetable.
For what?!
I ran into this problem when he wrote an application to form an university schedule. It is convenient to have their schedules separately, so even a standard calendar does not support repeating events in one week, which is necessary for a two-week (Thu / odd.) Schedule. Idée fixe was a function of the application, which will "fill" introduced by the schedule Android calendar. Pluses are obvious: Sync with Google Calendar from google (pardon the tautology), built-in calendar widget (very much good this widget from HTC Sense) and a mountain of widgets from third-party manufacturers, which show at least the next event, though utilization of the week, etc.
Use an undocumented API - this is BAD! Got it?Does that solve the problem of the obvious need to use an undocumented API? The answer - no. The proper method is to use the API Google Calendar, I advise you andmake my own applications.
But the "right" method imposes several limitations:
• Do not use the lack of connection to the Internet;
• the need to synchronize the calendar after filling;
• Data (and there are not enough in filling the whole year) go to the server and then goback in sync, which obviously increases the traffic in half.
In my opinion, is much more convenient to use the offline version of the calendar, whichat any opportunity, you can synchronize with guglokalendarem. Unfortunately google did not care about developers for Android and has not published an official API, but to our delight Android source code open and intelligent people have long found the magic URIcontent providers.
We ask the user for permission to work with calendar
Paradox. API does not have, and resolution of the documentation is. You just have toadd them to vashAndroidManifest.xml.
To use the calendar, Android, we must turn to its content provider for a particular URI.Much to our chagrin that the URI is different in different versions of operating systems andis likely to change in the next (the costs of undocumented API). But the problem is solved.
For Froyo [2.2] and is likely for the following versions-content: / / com.android.calendar / calendars.
For versions <2.2 - content: / / calendar / calendars.
As you can see, it's not so bad. You can determine the version of the system and use the appropriate URI, but I went the other way. I watch if there's a URI for <2.2 and if there is no one, then use the remainder.We assume that the URI received.
Get the list of calendars
For users of Google Calendar do not have to explain, and explain to the rest. Public Access consists of one or several small calendars, which can vary in color markers. This is usually something like "personal", "work", "training", etc. Establish such calendars canonly visit guglokalendarya, in the android that standard means you can do.
To add an event, we need to know the ID of the calendar. To perform this task, use the construction of the preceding paragraph.Now the resulting set of names can be displayed in the interface and allow the user to choose.
Add event
Then work with the calendar is, as with any other content provider. This can be read in the documentation.Let's talk about the fields of the event. The description field, I advise you to use to indicateevents. Use this field can then be removed en masse all the events generated by your program. Field names, descriptions and venue are string. We should also mention thetime field. These fields have type long, but these fields can be generated, for example,the following function.With her, I think, will understand themselves, let me note only that it responds to thecurrent time zone.
Remove Event
To delete a message by ID to add it to the URI.To remove the other fields you can get all mouse events, like we did with the calendars, and then selectively remove the ID.
Finally
In conclusion, I remind you that you're using it at your own risk. During development, Ionce wrote a URI is not and my phone every time you sync started to issue an error (corrected erasure of information from the calendar altogether.)
Another trouble - the emulator is no calendar, for it to repeat all the above fails.
And it concluded. I can not take the opportunity popiarit the application, which was discussed in the article. You can find it in the market under the name uTimetable.