how to directly pass value of a variable from 1st activity to 3rd activity using putextra?
For example:
I have a variable A in the first screen (first activity)
Actually its not possible to go from 1st activity to 3rd directly...
You must have to follow the activity stack..
So if you want the data to be passed from 1st to 3rd follow by
1st -> 2nd -> 3rd
with the use of intent suggested by @Lalit Poptani
You may keep them as static objects and retrieve as Myclass.myObject
. But what you really want is impossible.
You can use a database, SharedPreferences, Application, Static Methods and more for share data between Activitys. Look here
You can pass any value between any two Activities you want. You just need to do two things:
In your FirstActivity:
Intent intent = new Intent(context, ThirdActivity.class);
i.putExtra("value_key", value); //valus is a String
startActivity(intent);
In your ThirdActivity's onCreate()
:
Bundle b = getIntent().getExtras();
String value = (String) b.getString("value_key");