Re: [android-developers] Re: writing Events into Google Calendar in Android failed

2010-10-12 Thread Dianne Hackborn
Please note that the calendar provider is *not* part of the SDK, it *does*
change between platform releases, and you *will* have compatibility problems
if you are using it.

On Mon, Oct 11, 2010 at 8:31 AM, Kapuddi  wrote:

> Cool. Mr. Jens, you're right.
>
> First, I checked the content_id,
> then I set the content_id to 1.
> Succeed.
>
> Thank you.
>
> Also thanks to Mr Mr. Murphy.
>
> On 10月11日, 下午7时48分, Jens  wrote:
> > You're adding an event that's not linked to a row in the calendars
> > table for one.
> >
> > Typically you need to set the value of "calendar_id" to something.
> > This "something" better be a valid _id value from the calendars table
> > or your app will just be filling the provider with crap.
> >
> > If you're going to be messing around in undocumented providers you
> > should probably start by looking at the provider code itself:
> >
> > http://android.git.kernel.org/?p=platform/packages/providers/Calendar...
> >
> > Also.. the provider is a bit peculiar on all-day events.. plz make
> > sure you're pushing them in in UTC-time with the event time zone set
> > to UTC also. Look at the implementation in the Calendar app itself:
> >
> > http://android.git.kernel.org/?p=platform/packages/apps/Calendar.git;...
> >
> > --
> >
> > (or you could just do it with GDATA as M.Murphy suggests and push your
> > messages via HTTP up to Google which should sync it back to the device
> > sooner or later).
> >
> > On 8 Okt, 12:40, Kapuddi  wrote:
> >
> > > Hello, All:
> >
> > > when I insert one new Calendar Event into Google calendar from my app,
> > > the log message was given:
> > >
> 
> > > 10-05 00:30:44.171: ERROR/DatabaseUtils(8479): Error inserting
> > > transparency=0 dtstart=128589120 title=TestCalendar _sync_dirty=1
> > > dtend=128589120 visibility=0 allDay=1 lastDate=1285950628697
> > > hasAlarm=0 eventStatus=1 into table  Events
> > > 10-05 00:30:44.171: ERROR/DatabaseUtils(8479):
> > > android.database.sqlite.SQLiteConstraintException: error code 19:
> > > constraint failed
> > > 10-05 00:30:44.171: ERROR/DatabaseUtils(8479): at
> > > android.database.sqlite.SQLiteStatement.native_execute(Native Method)
> > >
> 
> >
> > > would you please tell me how to solve it?
> >
> > > Best Regards,
> >
> > > Kapuddi
> >
> > >
> 
> > > Next is my sample code:
> > > // Platform: android 2.2 froyo
> >
> > >private static final String calendarcontentStr =
> > > "content://com.android.calendar/events";
> >
> > >ContentValues event = new ContentValues();
> >
> > >//event.put("title", mAct.getString(R.string.read) + ": " + title);
> > >event.put("title", "TestCalendar");
> >
> > >long startTime = startC.getTimeInMillis();
> > >long endTime = endC.getTimeInMillis();
> >
> > >event.put("dtstart", startTime);
> > >event.put("dtend", endTime);
> > >//event.put("allDay", 1);
> > >event.put("eventStatus", 1);
> > >event.put("visibility", 0);
> > >event.put("transparency", 0);
> > >event.put("hasAlarm", 0);
> >
> > >Uri eventsUri = Uri.parse(calendarcontentStr);
> > >Uri uri = mAct.getContentResolver().insert(eventsUri, event);
>
> --
> 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
>



-- 
Dianne Hackborn
Android framework engineer
hack...@android.com

Note: please don't send private questions to me, as I don't have time to
provide private support, and so won't reply to such e-mails.  All such
questions should be posted on public forums, where I and others can see and
answer them.

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

[android-developers] Re: writing Events into Google Calendar in Android failed

2010-10-12 Thread M. Dodd
If you intend to use the provider directly you should not hard code
the calendar_id value to "1" - and instead determine this value each
time you create an event.

On 11 Okt, 17:31, Kapuddi  wrote:
> Cool. Mr. Jens, you're right.
>
> First, I checked the content_id,
> then I set the content_id to 1.
> Succeed.
>
> Thank you.
>
> Also thanks to Mr Mr. Murphy.
>
> On 10月11日, 下午7时48分, Jens  wrote:
>
> > You're adding an event that's not linked to a row in the calendars
> > table for one.
>
> > Typically you need to set the value of "calendar_id" to something.
> > This "something" better be a valid _id value from the calendars table
> > or your app will just be filling the provider with crap.
>
> > If you're going to be messing around in undocumented providers you
> > should probably start by looking at the provider code itself:
>
> >http://android.git.kernel.org/?p=platform/packages/providers/Calendar...
>
> > Also.. the provider is a bit peculiar on all-day events.. plz make
> > sure you're pushing them in in UTC-time with the event time zone set
> > to UTC also. Look at the implementation in the Calendar app itself:
>
> >http://android.git.kernel.org/?p=platform/packages/apps/Calendar.git;...
>
> > --
>
> > (or you could just do it with GDATA as M.Murphy suggests and push your
> > messages via HTTP up to Google which should sync it back to the device
> > sooner or later).
>
> > On 8 Okt, 12:40, Kapuddi  wrote:
>
> > > Hello, All:
>
> > > when I insert one new Calendar Event into Google calendar from my app,
> > > the log message was given:
> > > 
> > > 10-05 00:30:44.171: ERROR/DatabaseUtils(8479): Error inserting
> > > transparency=0 dtstart=128589120 title=TestCalendar _sync_dirty=1
> > > dtend=128589120 visibility=0 allDay=1 lastDate=1285950628697
> > > hasAlarm=0 eventStatus=1 into table  Events
> > > 10-05 00:30:44.171: ERROR/DatabaseUtils(8479):
> > > android.database.sqlite.SQLiteConstraintException: error code 19:
> > > constraint failed
> > > 10-05 00:30:44.171: ERROR/DatabaseUtils(8479): at
> > > android.database.sqlite.SQLiteStatement.native_execute(Native Method)
> > > 
>
> > > would you please tell me how to solve it?
>
> > > Best Regards,
>
> > > Kapuddi
>
> > > 
> > > Next is my sample code:
> > > // Platform: android 2.2 froyo
>
> > >private static final String calendarcontentStr =
> > > "content://com.android.calendar/events";
>
> > >ContentValues event = new ContentValues();
>
> > >//event.put("title", mAct.getString(R.string.read) + ": " + title);
> > >event.put("title", "TestCalendar");
>
> > >long startTime = startC.getTimeInMillis();
> > >long endTime = endC.getTimeInMillis();
>
> > >event.put("dtstart", startTime);
> > >event.put("dtend", endTime);
> > >//event.put("allDay", 1);
> > >event.put("eventStatus", 1);
> > >event.put("visibility", 0);
> > >event.put("transparency", 0);
> > >event.put("hasAlarm", 0);
>
> > >Uri eventsUri = Uri.parse(calendarcontentStr);
> > >Uri uri = mAct.getContentResolver().insert(eventsUri, event);

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


[android-developers] Re: writing Events into Google Calendar in Android failed

2010-10-11 Thread Kapuddi
Cool. Mr. Jens, you're right.

First, I checked the content_id,
then I set the content_id to 1.
Succeed.

Thank you.

Also thanks to Mr Mr. Murphy.

On 10月11日, 下午7时48分, Jens  wrote:
> You're adding an event that's not linked to a row in the calendars
> table for one.
>
> Typically you need to set the value of "calendar_id" to something.
> This "something" better be a valid _id value from the calendars table
> or your app will just be filling the provider with crap.
>
> If you're going to be messing around in undocumented providers you
> should probably start by looking at the provider code itself:
>
> http://android.git.kernel.org/?p=platform/packages/providers/Calendar...
>
> Also.. the provider is a bit peculiar on all-day events.. plz make
> sure you're pushing them in in UTC-time with the event time zone set
> to UTC also. Look at the implementation in the Calendar app itself:
>
> http://android.git.kernel.org/?p=platform/packages/apps/Calendar.git;...
>
> --
>
> (or you could just do it with GDATA as M.Murphy suggests and push your
> messages via HTTP up to Google which should sync it back to the device
> sooner or later).
>
> On 8 Okt, 12:40, Kapuddi  wrote:
>
> > Hello, All:
>
> > when I insert one new Calendar Event into Google calendar from my app,
> > the log message was given:
> > 
> > 10-05 00:30:44.171: ERROR/DatabaseUtils(8479): Error inserting
> > transparency=0 dtstart=128589120 title=TestCalendar _sync_dirty=1
> > dtend=128589120 visibility=0 allDay=1 lastDate=1285950628697
> > hasAlarm=0 eventStatus=1 into table  Events
> > 10-05 00:30:44.171: ERROR/DatabaseUtils(8479):
> > android.database.sqlite.SQLiteConstraintException: error code 19:
> > constraint failed
> > 10-05 00:30:44.171: ERROR/DatabaseUtils(8479): at
> > android.database.sqlite.SQLiteStatement.native_execute(Native Method)
> > 
>
> > would you please tell me how to solve it?
>
> > Best Regards,
>
> > Kapuddi
>
> > 
> > Next is my sample code:
> > // Platform: android 2.2 froyo
>
> >private static final String calendarcontentStr =
> > "content://com.android.calendar/events";
>
> >ContentValues event = new ContentValues();
>
> >//event.put("title", mAct.getString(R.string.read) + ": " + title);
> >event.put("title", "TestCalendar");
>
> >long startTime = startC.getTimeInMillis();
> >long endTime = endC.getTimeInMillis();
>
> >event.put("dtstart", startTime);
> >event.put("dtend", endTime);
> >//event.put("allDay", 1);
> >event.put("eventStatus", 1);
> >event.put("visibility", 0);
> >event.put("transparency", 0);
> >event.put("hasAlarm", 0);
>
> >Uri eventsUri = Uri.parse(calendarcontentStr);
> >Uri uri = mAct.getContentResolver().insert(eventsUri, event);

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


[android-developers] Re: writing Events into Google Calendar in Android failed

2010-10-11 Thread Jens
You're adding an event that's not linked to a row in the calendars
table for one.

Typically you need to set the value of "calendar_id" to something.
This "something" better be a valid _id value from the calendars table
or your app will just be filling the provider with crap.

If you're going to be messing around in undocumented providers you
should probably start by looking at the provider code itself:

http://android.git.kernel.org/?p=platform/packages/providers/CalendarProvider.git;a=tree;f=src/com/android/providers/calendar;h=240974b9e76a1c95fb7a20069e0848f913abbef7;hb=25b0f0ee070a5fff18cfcaffa86cb1607941c8a5

Also.. the provider is a bit peculiar on all-day events.. plz make
sure you're pushing them in in UTC-time with the event time zone set
to UTC also. Look at the implementation in the Calendar app itself:

http://android.git.kernel.org/?p=platform/packages/apps/Calendar.git;a=tree;f=src/com/android/calendar;h=e0c3f3cc9249fb9b0cf278a8338e362fdf3e9f4a;hb=14e77164bddf4d29acaca5bb2ff116a697bf9650

--

(or you could just do it with GDATA as M.Murphy suggests and push your
messages via HTTP up to Google which should sync it back to the device
sooner or later).


On 8 Okt, 12:40, Kapuddi  wrote:
> Hello, All:
>
> when I insert one new Calendar Event into Google calendar from my app,
> the log message was given:
> 
> 10-05 00:30:44.171: ERROR/DatabaseUtils(8479): Error inserting
> transparency=0 dtstart=128589120 title=TestCalendar _sync_dirty=1
> dtend=128589120 visibility=0 allDay=1 lastDate=1285950628697
> hasAlarm=0 eventStatus=1 into table  Events
> 10-05 00:30:44.171: ERROR/DatabaseUtils(8479):
> android.database.sqlite.SQLiteConstraintException: error code 19:
> constraint failed
> 10-05 00:30:44.171: ERROR/DatabaseUtils(8479):     at
> android.database.sqlite.SQLiteStatement.native_execute(Native Method)
> 
>
> would you please tell me how to solve it?
>
> Best Regards,
>
> Kapuddi
>
> 
> Next is my sample code:
> // Platform: android 2.2 froyo
>
>    private static final String calendarcontentStr =
> "content://com.android.calendar/events";
>
>    ContentValues event = new ContentValues();
>
>    //event.put("title", mAct.getString(R.string.read) + ": " + title);
>    event.put("title", "TestCalendar");
>
>    long startTime = startC.getTimeInMillis();
>    long endTime = endC.getTimeInMillis();
>
>    event.put("dtstart", startTime);
>    event.put("dtend", endTime);
>    //event.put("allDay", 1);
>    event.put("eventStatus", 1);
>    event.put("visibility", 0);
>    event.put("transparency", 0);
>    event.put("hasAlarm", 0);
>
>    Uri eventsUri = Uri.parse(calendarcontentStr);
>    Uri uri = mAct.getContentResolver().insert(eventsUri, event);

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