Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Bundle getExtras with Calendar Object

Is it possible to pass Calendar Objects from one Activtity to another with intents? I get true for the hasExtra("startDate") but i cannot get the Object itself... sorry for the beginner question.

// Activity Two
Intent resultIntent = new Intent();
resultIntent.putExtra("endDate", endDate);
resultIntent.putExtra("startDate", endDate);
setResult(AppCompatActivity.RESULT_OK, resultIntent);


//Activity One
Bundle newText = data.getExtras();
data.hasExtra("startDate")); // returns true
newText.get("startDate") // returns null
like image 670
Florian Avatar asked Mar 16 '26 06:03

Florian


1 Answers

Assuming that you mean java.util.Calendar, that implements Serializable, so you can use putExtra() and getSerializableExtra().

like image 189
CommonsWare Avatar answered Mar 18 '26 21:03

CommonsWare



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!