Start an Activity with a parameter
Put an int
which is your id into the new Intent
.
Intent intent = new Intent(FirstActivity.this, SecondActivity.class);
Bundle b = new Bundle();
b.putInt("key", 1); //Your id
intent.putExtras(b); //Put your id to your next Intent
startActivity(intent);
finish();
Then grab the id in your new Activity
:
Bundle b = getIntent().getExtras();
int value = -1; // or other values
if(b != null)
value = b.getInt("key");
Just add extra data to the Intent you use to call your activity.
In the caller activity :
Intent i = new Intent(this, TheNextActivity.class);
i.putExtra("id", id);
startActivity(i);
Inside the onCreate() of the activity you call :
Bundle b = getIntent().getExtras();
int id = b.getInt("id");