views:

1063

answers:

1

Hi,

The main activity includes some variables with set values. I created a sub-activity with the form which has to be filled with the data from main activity so I guess the data have to be passed to the sub-activity when it starts.

Does anyone know how to pass the variable values to the sub-activity from the main activity?

Thanks!

+6  A: 

You can use this method in your main activity

Intent i = new Intent(this, YourMainClass.class);
i.putExtra("key", value);

end then in the sub activity get the value with this method, usually in the onCreate event

int value = getIntent().getExtras().getInt("key");

I hope this hepls.

tdelev