Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Android™ Runtime Development

Reply
New Developer
lionscribe
Posts: 11
Registered: ‎05-05-2009
My Device: Not Specified
Accepted Solution

Blackberry Calendar Event Creation

Does anyone know how to create a calendar event using an intent? Blackberry has been touting its availability since December, see http://http://devblog.blackberry.com/2012/12/android-runtime-for-blackberry-10-gold-release/. I have tried the following, but it doesn't work.

 

	    	Intent intent = new Intent(Intent.ACTION_INSERT);
	    	intent.setData(Events.CONTENT_URI);
	    	intent.putExtra(CalendarCompatibility.EXTRA_EVENT_BEGIN_TIME, startMillis);
	    	intent.putExtra(CalendarCompatibility.EXTRA_EVENT_END_TIME, endMillis);
	    	intent.putExtra(CalendarCompatibility.EXTRA_EVENT_ALL_DAY, allDayEvent);
	        mContext.startActivity(intent);

 Thanks in advance,

Lionscribe

Please use plain text.
Contributor
Sriman
Posts: 32
Registered: ‎02-26-2012
My Device: Playbook
My Carrier: None

Re: Blackberry Calendar Event Creation

It does not work... I have tried it before also...
Please use plain text.
BlackBerry Development Advisor
bbenninger
Posts: 130
Registered: ‎04-19-2013
My Device: BlackBerry Z10

Re: Blackberry Calendar Event Creation

Try Intent.ACTION_EDIT instead of Intent.ACTION_INSERT.

 

Looking at the Calendar app's manifest for Gingerbread, it doesn't handle the Intent.ACTION_INSERT.  I'm not sure why.

Please use plain text.
New Developer
lionscribe
Posts: 11
Registered: ‎05-05-2009
My Device: Not Specified

Re: Blackberry Calendar Event Creation

It does not help using Intent.ACTION_EDIT

Intent.ACTION_INSERT was added in HoneyComb, therefore it's not in Gingerbread Android Calendar.

But we are talking about the Blackberry Native Calendar, and it is supposed to intercept an Intent, and show the native calendar.

So how do we do it?

 

Please use plain text.
BlackBerry Development Advisor
bbenninger
Posts: 130
Registered: ‎04-19-2013
My Device: BlackBerry Z10

Re: Blackberry Calendar Event Creation

The code that handles adding events to the native calendar mimics the intents you'd use to add to the android calendar.  So you have to use the same intents you'd use in Gingerbread.

Please use plain text.
New Developer
lionscribe
Posts: 11
Registered: ‎05-05-2009
My Device: Not Specified

Re: Blackberry Calendar Event Creation

Well, the Gingerbread calendar officially didn't support creating events via intents...

Looking at the Android source code it is possible using the following;

 

Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("beginTime", startMillis);
intent.putExtra("endTime", endMillis);
intent.putExtra("allDay", allDayEvent);

 It works, but;

The beginTime & endTime are ignored!

Also, Subject & Location are prefilled with "null"

 

Can someone telll us what is the right way to do it in Blackberryy?

 

Thanks

Please use plain text.
BlackBerry Development Advisor
bbenninger
Posts: 130
Registered: ‎04-19-2013
My Device: BlackBerry Z10

Re: Blackberry Calendar Event Creation

[ Edited ]

This is the only way to do it for BlackBerry.

 

This is also poorly documented, we should probably fix this.

 

Use the following

 

"dtstart" for start time

"dtend" for end time

"title" for subject

"eventLocation" for location

 

(Specifically, android.provider.Calendar.Events START/STOP/TITLE/EVENT_LOCATION)

 

I'll look into getting this cleaned up a bit.  We should add support for the officially supported way (in addition to keeping this).

 

Please use plain text.
BlackBerry Development Advisor
bbenninger
Posts: 130
Registered: ‎04-19-2013
My Device: BlackBerry Z10

Re: Blackberry Calendar Event Creation

Also if you don't want to set a subject and location, and you don't want it to be set to "null" (this is a bug) then set those extra's to an empty string.

Please use plain text.
New Developer
lionscribe
Posts: 11
Registered: ‎05-05-2009
My Device: Not Specified

Re: Blackberry Calendar Event Creation

Thank you for replying, but...

"title" & "eventLocation" work,

but "dtstart" & "dtend" do not!

I am passing to them milliseconds since epoch (as in android.provider.Calendar). Maybe you are supposed to pass something else?

 

Thanks in advance,

Lionscribe

Please use plain text.
BlackBerry Development Advisor
bbenninger
Posts: 130
Registered: ‎04-19-2013
My Device: BlackBerry Z10

Re: Blackberry Calendar Event Creation

[ Edited ]

dtstart / dtend are not in milliseconds, it's in date format (apparently).  E.G 2013-05-27 ... (yyyy-MM-dd HH:mm:ss).

 

Going forward in 10.2 we'll properly support "beginTime" and "endTime" as a long extra.

Please use plain text.