Skip to content Skip to sidebar Skip to footer

Using Integers, Strings Etc In Other Activities

I've got two Activities. In one I calculate some things and therefore I have some Integers and also some Strings stored. So now I would like to use these Stings and Integers in my

Solution 1:

You gotta pass them to your second activity.

When you create Intent to start activity

Intent i = newIntent(FirstActivity.this, SecondActivity.class);

do extra step like this

i.putExtra("integer", myInteger); //where myInteger is integer you have in first Activityi.putExtra("string", myString); //where myString is String you have in first ActivitystartActivity(i);

and now in second Activity to access those values use following code

intin=this.getIntent().getExtras().getInt("integer");
Stringstr=this.getIntent().getExtras().getString("string");

as simple as that

Post a Comment for "Using Integers, Strings Etc In Other Activities"