2012-04-20 36 views
0

我putExtras的getSerializableExtra日历中的活动答:我不能恢复使用意向

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

我getExtras EN活动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? 

我在做什么错。提前致谢。

+1

你为什么要那样做?只需在每个活动中创建一个日历。 'Calendar'只是日期和时间计算的帮手。如果你想传递一个时间点,使用'java.util.Date'类或毫秒作为'long'。 – Stephan 2012-04-20 15:16:42

+0

有时我们离树很近,以至于看不到森林。谢谢。我会用很长的毫秒。 – Jesus 2012-04-20 19:17:31

回答

0

您无法序列化整个日历对象并使用Extra来发送它。您只能发送基元,数组和字符串。您可能需要考虑Parcellable等替代方案。