Android app using Google calendar - Sync issue

半城伤御伤魂 提交于 2019-12-19 02:47:21

问题


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.

  1. 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 ?

  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!