Great -- thanks.

So I just moved my code over.  My observations of the new Calendar
Content Provider vs. the one from SDK 8:

- Same URI
- Same logic works for reading the list of Calendars and creating/
reading Events and Reminders (only operations I am doing).
- A couple of the column names have been changed -- they have been
prepended with "calendar_"

So, in other words, if you just fix up the column names, the same code
works as before.



On Nov 8, 3:04 am, Michael Chan <mc...@android.com> wrote:
> Hi,
>
> > Are you saying there is no way to help the user subscribe to a public> 
> > google calendar via the new calendar api?
>
> There just isn't a *supported* way via the Android Calendar API. (You
> can always do some reverse engineering and get something that work for
> now. But it may break suddenly one day when the user gets an update.
> So I really really want discourage everyone from doing that.)
>
> > Is there a better, more supported way to do this?
>
> The only supported way today is to talk to the server directly via the
> GData api.  You need to figure out how to get the 
> credentials.http://code.google.com/apis/calendar/data/2.0/developers_guide.html
> Looks like the code below is doing that.
>
> > Also what do you mean by using the browser?  Can I make the calendar
> > visible and sync'ed via the browser?
>
> 2 way:
> 1) Instruct the user to do it manually
> 2) Send the user tohttps://www.google.com/calendar/render?cid=<calendar ID> 
> orhttp://www.google.com/calendar/hosted/<domain>/render?cid=<calendar
> ID>. The user has to say they want to use the desktop UI, zoom in, and
> click "Yes, add this calendar". It is not a great experience.  The
> other drawback here is that the user won't be able to choose which
> account the calendar should be added to.
>
> Thanks,
> Mike
>
>
>
> On Fri, Nov 4, 2011 at 6:13 PM, Ralph <fed...@gmail.com> wrote:
> > Hi Michael,
>
> > Thanks again.
>
> > Are you saying there is no way to help the user subscribe to a public
> > google calendar via the new calendar api?
>
> > I am already subscribing using some example from Yaniv Inbar a while
> > back:
>
> > where ALERT_CALENDAR is "nyc.ale...@brooklynmarathon.com"
>
> > Is there a better, more supported way to do this?
>
> > Also what do you mean by using the browser?  Can I make the calendar
> > visible and sync'ed via the browser?
>
> > Thanks,
> > Ralph
>
> >  private void subscribeCalendar()
> >  {
> >    CalendarUrl url  = CalendarUrl.forAllCalendarsFeed();
> >    Log.i(TAG,"ADD NEW CALENDAR: " + url);
> >    CalendarEntry calendar = new CalendarEntry();
> >    //calendar should have something like setid of gdata api
>
> >    calendar.id = ALERT_CALENDAR;
> >    //calendar.title = "Test: " + new DateTime(new Date());
> >    try {
> >      calendar.executeInsert(transport, url);
>
> >      AlertDialog builder;
> >      try {
> >          builder = MessageDialogBuilder.create(this, MESSAGE );
> >          builder.show();
> >      } catch (NameNotFoundException e) {
> >          // TODO Auto-generated catch block
> >          e.printStackTrace();
> >      }
> >    } catch (IOException e) {
> >      handleException(e);
> >    }
>
> >  }
>
> > On Nov 4, 12:38 pm, Michael Chan <mc...@android.com> wrote:
> >> Hi Ralph,
>
> >> I wish I have a solution for you. That's not supported right now. The only
> >> (not so good) way is to use the browser. I will file an internal feature
> >> request if we don't have one already.
>
> >> Thanks,
> >> Mike
>
> >> On Fri, Nov 4, 2011 at 7:24 AM, Ralph <fed...@gmail.com> wrote:
> >> > Hi Michael and thank you.
>
> >> > Can you let us know the recommended way to subscribe a user to a
> >> > public google calendar.
>
> >> > For example, let's say you have a google calendar with public
> >> > information.  for example, some city alerts etc. data.
>
> >> > We want to make it easy for the user to subscribe to the public
> >> > calendar and make it sync'ed and visible (with their permission of
> >> > course)
>
> >> > Today, I have to give them instructions and it seems that each phone
> >> > manufacturer has implemented the calendar in a different way so the
> >> > instructions are very complicated.  What I'd like to send the user to
> >> > a screen with the calendar subscription (visible and sync'ed) already
> >> > set up and let them confirm it.
>
> >> > Thanks,
> >> > Ralph
>
> >> > On Nov 3, 2:29 pm, Michael Chan <mc...@android.com> wrote:
> >> > > 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));
> >> > > >
>
> ...
>
> read more »- Hide quoted text -
>
> - Show quoted text -

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

Reply via email to