Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android app using Google calendar - Sync issue

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 ?

like image 782
ango Avatar asked Apr 15 '12 22:04

ango


1 Answers

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

like image 90
0xPixelfrost Avatar answered Sep 22 '22 16:09

0xPixelfrost