I'm building an application for students to manage the courses of a university.
Now I would like to synchronize the events (an event has a date and time and a brief description) with the google calendar of Android.
I took a look at the samplesync adapter from the Android sample, but I didn't find it very useful for the calendar.
The sync of the app should be enabled and disabled from the settings of the app with a checkbox.
Does anyone has some sample code that can be useful??
Use
android.preference.PreferenceActivity
to make your preference page.Ensure that your app updates the checkbox on the preference page with the value from the system before it opens. (The setting may have been changed in the Accounts & Sync system control panel.) Use
ContentResolver.getSyncAutomatically(Account account, String authority)
to read the system valueCommand the system to match the PreferenceActivity setting using
ContentResolver.setSyncAutomatically(Account account, String authority, boolean sync)
--Note that you can't control sync on a provider -- you control it for an account/provider pair. Your app will need to keep a copy of the Account it is set to use so it can pass it in these calls.