问题
I am trying to create an android app that interfaces with the Google Calendar.
I have followed the tutorial using content providers from here. Parts of this code are explained here.
I am facing the below issues.
I created a new calendar TestCalendar from my online from my laptop, and marked it as Selected. When I query for my calendars from the app, I can see this new calendar, but it is shown as unselected (selected=0). Any suggestions on why this could be happening ?
From my app, I add an event to the calendar by
getContentResolver().insert(eventsUri, event);
The event is reflected in the calendar on phone, but it is not reflected in the online version. To push this new event online, I have to manually Synchronize the calendar, or turn the Auto Sync on, which I believe is not the right way in which this should be done. Any suggestions/links which could help ?
回答1:
1) Can you dump your calendar and post the result?
Notice:
Android < API Lvl 14 you must set selected = 1
Android > API Lvl 14 you must set visible = 1 (selected is not longer available)
Dump:
cursor = contentResolver.query(Uri.parse(CALENDAR_URI),null, null, null,null);
while (cursor.moveToNext()) {
for (int i = 0; i < cursor.getColumnCount(); i++) {
Log.e("XXX", cursor.getColumnName(i) + ": " + cursor.getString(i));
}
}
CALENDAR_URI = content://com.android.calendar/calendars (since Froyo) or content://calendar/ (before Froyo)
2) https://stackoverflow.com/a/11652415/411951
来源:https://stackoverflow.com/questions/10166621/android-app-using-google-calendar-sync-issue