0

I putExtras in Activity A:

notificationIntent.putExtra(KEY_ID, id);
notificationIntent.putExtra(KEY_CALENDAR, day);
A.logCalendar("calendar: ", day); // the Calendar is not null at this point

I getExtras en Activity B:

int id = intent.getIntExtra(Constantes.KEY_ID, 0);
A.b("My id: " + id); // The id is recovery
Calendar time = (Calendar) intent.getSerializableExtra(Constantes.KEY_CALENDAR);
if (time == null)
    A.b("null calendar"); // The calendar is always null, WHY?

What I'm doing wrong. Thanks in advance.

Alpha75
  • 2,140
  • 1
  • 26
  • 49
  • 1
    Why would you do that? Just create one calendar in each activity. `Calendar` is only a helper for date and time calculation. If you want to pass a point in time, use the `java.util.Date` class or the milliseconds as `long`. – Stephan Apr 20 '12 at 15:16
  • Sometimes we are so close of the tree that we can't see the forest. Thanks. I'll use a long with milliseconds. – Alpha75 Apr 20 '12 at 19:17

1 Answers1

0

You can't serialize entire Calendar object and send it using Extra. You can send only primitives, arrays and String. You may need to consider alternatives like Parcellable.

kosa
  • 65,990
  • 13
  • 130
  • 167