I'm trying to pass an int
variable to another activity:
From the current activity:
Intent intent = new Intent(getApplicationContext(),PlayActivity.class);
intent.putExtra("position", position);
startActivity(intent);
At PlayActivity.onCreate
:
Intent intent = getIntent();
String position = intent.getStringExtra("position");
int index = Integer.parseInt(position);
Problem is, position is always null
(and parseInt()
throws exception).
Why?