Turns out that the value in beginTime and endTime has to be the value
of milliseconds since the epoch, so it should have been:
if(mEvent.getStartTime() != null)
intent.putExtra(Event.EVENT_BEGIN_TIME, mEvent.getStartTime().toMillis
(false));
if(mEvent.getStopTime() != null)
intent.putExtra(Event.EVENT_END_TIME, mEvent.getStopTime().toMillis
(false));
On Aug 4, 6:57 pm, CaseyB <[email protected]> wrote:
> I am having trouble starting a Calendar EditEvent activity with the
> correct info. I have a simple Event class that holds all of my
> information and on the selection of a menu item I pass the information
> to the EditEvent activity and all of it shows up correctly except the
> date and time. It always populates with the current date and time
> with an event duration of 1 hour. That is unless the allDay flag is
> set, then it's just the current date. Is there something wrong with
> how I'm formatting the time? It comes across in the format
> yyyyMMddTHHmmss.
>
> public class Event
> {
> public static final String EVENT_BEGIN_TIME = "beginTime";
> public static final String EVENT_END_TIME = "endTime";
> public static final String EVENT_ALL_DAY = "allDay";
> public static final String EVENT_TITLE = "title";
> public static final String EVENT_DESCRIPTION = "description";
> public static final String EVENT_LOCATION = "eventLocation";
>
> private String mTitle;
> private String mDescription;
> private Time mStartTime;
> private Time mStopTime;
> private boolean mAllDay;
> private String mVenueName;
>
> public String getTitle() { return mTitle; }
> public void setTitle(String title) { mTitle = title; }
>
> public String getDescription() { return mDescription; }
> public void setDescription(String description) { mDescription =
> description; }
>
> public Time getStartTime() { return mStartTime; }
> public void setStartTime(Time startTime) { mStartTime = startTime; }
>
> public Time getStopTime() { return mStopTime; }
> public void setStopTime(Time stopTime) { mStopTime = stopTime; }
>
> public boolean isAllDay() { return mAllDay; }
> public void setAllDay(boolean allDay) { mAllDay = allDay; }
>
> public String getVenueName() { return mVenueName; }
> public void setVenueName(String venueName) { mVenueName =
> venueName; }
>
> }
>
> @Override
> public boolean onOptionsItemSelected(MenuItem item)
> {
> if(item.getItemId() == _SEND_TO_CALENDAR_)
> {
> Intent intent = new Intent(Intent.ACTION_EDIT);
> intent.setType("vnd.android.cursor.item/event");
> if(mEvent.getStartTime() != null)
> intent.putExtra(Event.EVENT_BEGIN_TIME,
> mEvent.getStartTime
> ().format2445());
> if(mEvent.getStopTime() != null)
> intent.putExtra(Event.EVENT_END_TIME,
> mEvent.getStopTime
> ().format2445());
> intent.putExtra(Event.EVENT_ALL_DAY, mEvent.isAllDay());
> intent.putExtra(Event.EVENT_TITLE, mEvent.getTitle());
> intent.putExtra(Event.EVENT_LOCATION, mEvent.getVenueName());
> intent.putExtra(Event.EVENT_DESCRIPTION,
> mEvent.getDescription());
> startActivity(intent);
>
> return true;
> }
>
> }
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---