I have question about sending object to other activity. Im not sure about this what im doing. So i have object Player in MainActivity
final Player player = new Player("Player", 150);
I have separate class for Player with simple constructor
public class Player {
private String playerName;
private double playerCash;
Player(String playerName, double playerCash)
{
this.playerName = playerName;
this.playerCash = playerCash;
}
And i have second Activity , where i want use Player object. I made a button in MainActivity with this code
mButton = (Button) findViewById(R.id.mButton);
mButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent(MainActivity.this, SecondActivity.class);
intent.putExtra("player", player);
startActivity(intent);
}
});
And now i got problem "Cannot resolve method putExtra". What am i doing wrong? I want only one Player object and want to use it in multiple activities but have no idea how. For any help, big thanks ;)