Let's say in Activity A (Score) I create instances of my custom class Player. How can I send these objects to Activity C, without needing to deal with them in Activity B (SelectGamemode)? This is how I send the objects via Parcelable from Activity A to B.
btnNewRound = (Button) findViewById(R.id.btnNewRound);
btnNewRound.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(Score.this, SelectGamemode.class);
Bundle bundle = new Bundle();
bundle.putParcelable("EXTRA_PLAYER_1", player1);
bundle.putParcelable("EXTRA_PLAYER_2", player2);
bundle.putParcelable("EXTRA_PLAYER_3", player3);
bundle.putParcelable("EXTRA_PLAYER_4", player4);
intent.putExtras(bundle);
startActivity(intent);
}
});
Now I would access my Player objects in Activity B like this:
player1= (Player)getIntent().getParcelableExtra("EXTRA_PLAYER_1");
Then in Activity B I would basically use the same code as in Activity A to send the Player objects to Activity C, although I don't even use the objects in Activity B. How can this be avoided? Thank you!