views:

241

answers:

1

I would like to pass some variables in the constructor of my ListActivity

I start activity via this code:

startActivity(new Intent (this, viewContacts.class));

I would like to use similar code, but to pass two strings to the constructor. How is possible?

+6  A: 

I think you want something like this:

Intent foo = new Intent(this, viewContacts.class);
foo.putExtra("myFirstKey", "myFirstValue");
foo.putExtra("mySecondKey", "mySecondValue");
startActivity(foo);

or you can combine them into a bundle first. Corresponding getExtra() routines exist for the other side. See the intent topic in the dev guide for more information.

RickNotFred