Hi, I believe the GoogleCalendarSyncAdapter was not included in the emulator. That's why you can't sync Google Calendars in the emulator.
The new Calendar API will support viewing, adding events (not calendars) via Intents. The user will need to confirm before the event is saved. Adding *Google* calendars via the provider is not supported at this time. We will be publishing a developer guide for Calendar APIs with more details on the set of supported intents as well as code snippets. managedQuery has been deprecated. It can cause ANRs. The recommend way is to use a CursorLoader (http://developer.android.com/reference/ android/content/CursorLoader.html). If you just need to read the data and can close the query immediately, you can still do a query (in a non-UI thread), read the data you want, and close the cursor. Thanks, Mike On Nov 3, 8:20 am, Ralph <fed...@gmail.com> wrote: > Thanks again. > > I can say that if you have access to an exchange server then the > following examples do work in the android 4.0 level 14 emulator using > google apis at the moment: > > Insert an event via Intents: > Intent intent = new Intent(Intent.ACTION_INSERT) > .setType("vnd.android.cursor.item/event") > .putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, > 0) > .putExtra(CalendarContract.EXTRA_EVENT_END_TIME, > 1000) > .putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY , > false) // just included for completeness > .putExtra(Events.TITLE, "My Awesome Event") > .putExtra(Events.DESCRIPTION, "Heading out with > friends to do something awesome.") > .putExtra(Events.EVENT_LOCATION, "Earth") > .putExtra(Events.RRULE, "FREQ=DAILY;COUNT=10") > .putExtra(Events.AVAILABILITY, > Events.AVAILABILITY_BUSY) > .putExtra(Events.ACCESS_LEVEL, > Events.ACCESS_PRIVATE) > .putExtra(Intent.EXTRA_EMAIL, > "my.fri...@example.com"); > startActivity(intent); > > Enumerate: > > Uri uri = CalendarContract.Calendars.CONTENT_URI; > Log.i(TAG, "QQQ: uri: " + uri); > String[] projection = new String[] { > CalendarContract.Calendars._ID, > CalendarContract.Calendars.ACCOUNT_NAME, > CalendarContract.Calendars.ACCOUNT_TYPE, > CalendarContract.Calendars.NAME, > > CalendarContract.Calendars.CALENDAR_DISPLAY_NAME, > CalendarContract.Calendars.CALENDAR_COLOR, > > CalendarContract.Calendars.CALENDAR_ACCESS_LEVEL, > CalendarContract.Calendars.OWNER_ACCOUNT, > CalendarContract.Calendars.SYNC_EVENTS, > CalendarContract.Calendars.CALENDAR_TIME_ZONE, > CalendarContract.Calendars.ALLOWED_REMINDERS, > CalendarContract.Calendars.VISIBLE > > }; > > Cursor calendarCursor = managedQuery(uri, projection, > null, null, null); > Log.i(TAG, "cursor: " + calendarCursor); > if (calendarCursor != null) > { > while (calendarCursor.moveToNext()) > { > //Log.i(TAG, "queryDatabase: title: " + > cursor.getString(cursor.getColumnIndex(Notes.TITLE)) + " note: " + > cursor.getString(cursor.getColumnIndex(Notes.NOTE))); > Log.i(TAG, "QQQ2: cursor: _ID: " + > calendarCursor.getColumnIndex(CalendarContract.Calendars._ID)); > for (int i = 0; i < > calendarCursor.getColumnCount(); i++) { > Log.i(TAG, "QQQ2: cursor: name: " + i > + " = > " + calendarCursor.getColumnName(i)); > Log.i(TAG, "QQQ2: cursor: type: " + i > + " = > " + calendarCursor.getType(i)); > switch(calendarCursor.getType(i)){ > case Cursor.FIELD_TYPE_STRING: > Log.i(TAG, "QQQ3: cursor: > value: " + i + " > = " + calendarCursor.getString(i)); > break; > case Cursor.FIELD_TYPE_INTEGER: > Log.i(TAG, "QQQ3: cursor: > value: " + i + " > = " + calendarCursor.getInt(i)); > break; > case Cursor.FIELD_TYPE_FLOAT: > Log.i(TAG, "QQQ3: cursor: > value: " + i + " > = " + calendarCursor.getFloat(i)); > break; > > } > > } > > } > } > } > > On Nov 3, 10:13 am, Mark Murphy <mmur...@commonsware.com> wrote: > > > > > > > > > There are no samples in the SDK. I do not know if the content provider > > works in the emulator. I was planning on waiting until the source code > > for ICS ships, at which point we can start to fill in the > > documentation gaps. > > > On Thu, Nov 3, 2011 at 9:57 AM, Ralph <fed...@gmail.com> wrote: > > > Hi Mark, > > > > Thanks so much. > > > > When I try to subscribe to a public google calendar via Intent on > > > Android Ice Cream Sandwich Level 14 emulator something like this: > > > > Does anyone know how to subscribe to a public calendar via the api or > > > know where the test cases are? Thanks. > > > > Intent intent = new Intent(Intent.ACTION_INSERT) > > > .setData(CalendarContract.Calendars.CONTENT_URI) > > > .putExtra(CalendarContract.Calendars.ACCOUNT_NAME, > > > "nyc.ale...@brooklynmarathon.com") > > > .putExtra(CalendarContract.Calendars.ACCOUNT_TYPE, > > > "com.google.calendar") > > > .putExtra(CalendarContract.Calendars.NAME, "NAME: > > > nyc.ale...@brooklynmarathon.com") > > > > > > .putExtra(CalendarContract.Calendars.CALENDAR_DISPLAY_NAME, > > > "CALENDAR_DISPLAY_NAME: nyc.ale...@brooklynmarathon.com") > > > .putExtra(CalendarContract.Calendars.CALENDAR_COLOR, > > > 0xff0000) > > > > > > .putExtra(CalendarContract.Calendars.CALENDAR_ACCESS_LEVEL, > > > 700) > > > .putExtra(CalendarContract.Calendars.OWNER_ACCOUNT, > > > "nyc.ale...@brooklynmarathon.com") > > > .putExtra(CalendarContract.Calendars.SYNC_EVENTS, > > > 1) > > > > > > .putExtra(CalendarContract.Calendars.CALENDAR_TIME_ZONE, > > > "GMT") > > > .putExtra(CalendarContract.Calendars.ALLOWED_REMINDERS, > > > "0,1") > > > .putExtra(CalendarContract.Calendars.VISIBLE, 1); > > > > startActivity(intent); > > > > I get: > > > > W/ContentResolver( 4166): Failed to get type for: > > > content://com.android.calendar/calendars > > > (Unknown URL content://com.android.cale > > > ndar/calendars) > > > I/ActivityManager( 74): START {act=android.intent.action.INSERT > > > dat=content://com.android.calendar/calendars (has extras)} from > > > pid 4166 > > > D/AndroidRuntime( 4166): Shutting down VM > > > W/dalvikvm( 4166): threadid=1: thread exiting with uncaught exception > > > (group=0x409951f8) > > > E/AndroidRuntime( 4166): FATAL EXCEPTION: main > > > E/AndroidRuntime( 4166): android.content.ActivityNotFoundException: No > > > Activity found to handle Intent { act=android.intent.action > > > .INSERT dat=content://com.android.calendar/calendars (has extras) } > > > E/AndroidRuntime( 4166): at > > > android.app.Instrumentation.checkStartActivityResult(Instrumentation.java: > > > 1512) > > > E/AndroidRuntime( 4166): at > > > android.app.Instrumentation.execStartActivity(Instrumentation.java: > > > 1384) > > > E/AndroidRuntime( 4166): at > > > android.app.Activity.startActivityForResult(Activity.java:3190) > > > E/AndroidRuntime( 4166): at > > > android.app.Activity.startActivity(Activity.java:3297) > > > E/AndroidRuntime( 4166): at > > > com.brooklynmarathon.calendarapi2.CalendarAPI2Activity > > > $3.onClick(CalendarAPI2Activity.java:164) > > > > E/AndroidRuntime( 4166): at > > > android.view.View.performClick(View.java:3460) > > > E/AndroidRuntime( 4166): at android.view.View > > > $PerformClick.run(View.java:13955) > > > E/AndroidRuntime( 4166): at > > > android.os.Handler.handleCallback(Handler.java:605) > > > E/AndroidRuntime( 4166): at > > > android.os.Handler.dispatchMessage(Handler.java:92) > > > E/AndroidRuntime( 4166): at android.os.Looper.loop(Looper.java: > > > 137) > > > E/AndroidRuntime( 4166): at > > > android.app.ActivityThread.main(ActivityThread.java:4340) > > > E/AndroidRuntime( 4166): at > > > java.lang.reflect.Method.invokeNative(Native Method) > > > E/AndroidRuntime( 4166): at > > > java.lang.reflect.Method.invoke(Method.java:511) > > > E/AndroidRuntime( 4166): at com.android.internal.os.ZygoteInit > > > $MethodAndArgsCaller.run(ZygoteInit.java:784) > > > E/AndroidRuntime( 4166): at > > > com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) > > > E/AndroidRuntime( 4166): at > > > dalvik.system.NativeStart.main(Native Method) > > > > On Nov 3, 8:26 am, Mark Murphy <mmur...@commonsware.com> wrote: > > >> I am assuming that they mean ACTION_INSERT, ACTION_EDIT, ACTION_VIEW, > > >> ACTION_PICK, etc. on eitherCalendarContract.CONTENT_URI > > >> orCalendarContract.Events.CONTENT_URI. I have not tried these yet. > > > >> On Thu, Nov 3, 2011 at 6:56 AM, Ralph <fed...@gmail.com> wrote: > > >> > But the announcement below refers to intents but it also says once the > > >> > new apis arrive > > > >> > when do the new apis arrive? > > > >> > From google: > > >> > "We want to see lots of good calendar apps and extensions that work > > >> > reliably across Android devices, and aren't broken by platform > > >> > updates. So we decided to create a clean API, including a > > >> > comprehensive set of Intents, to manage calendar data in ICS. Now > > >> > anyone can code against these new APIs and know that Android is > > >> > committed to supporting them, and that partners have to support these > > >> > APIs as part of CTS. > > > >> > Once the new APIs arrive, you’re ..." > > > >> > On Nov 2, 11:06 pm, Zsolt Vasvari <zvasv...@gmail.com> wrote: > > >> >> The ICS has not been relased. There are no "Intents". It's a > > >> >> ContentProvider. > > > >> >> On Nov 3, 11:04 am, Ralph <fed...@gmail.com> wrote: > > > >> >> > Hi > > > >> >> > And thanks. > > > >> >> > I see in the ICS announcement that the calender API and intents are > > >> >> > documented or at least that > > ... > > read more » -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en