I'm trying to send an object from one Activity to another.
@Override
public void onClick(View view) {
//Send the intent to ChallengeViewActivity class
Intent intent = new Intent(context, ChallengeViewActivity.class);
intent.putExtra("Challenge", currentChallenge); // currentChallenge is a Challenge object
context.startActivity(intent);
}
So over at the receiving class: ChallengeViewActivity:
Intent intent = getIntent();
Challenge challenge = (Challenge)intent.getExtras().getSerializable("Challenge");
This throws a:
ClassCastException: java.util.HashMap cannot be cast to alm.motiv.AlmendeMotivator.models.Challenge
I have no clue why java think I want to cast this to a hash map. If you could give me some insight and a possible solution to this problem I'd be really gratefull!