I have three activities. A, B and C. I press a button to open the B through startActivity(intent)
. From the BI pass data back to A through intent.putExtra()
and then, from AI get the data through getIntent
. I'm putting this data in a String on my A. The problem is that when I try to do the same with C. The data that I get from the B disappears. My question is: How can I get data from two activities?
Do you want to pass data from activity B to C via A?
If its that what I understand,then follow the foll steps:
Calling A from B:
Intent i=new Intent(getApplicationContext(),A.class);
i.putExtra("key","value");
startAtivity(i);
Fetching data from intent in class A:
Bundle extras = getIntent().getExtras();
String value=extras.getString("key");
Passing same data to activity C from class A:
Intent i=new Intent(getApplicationContext(),C.class);
i.putExtra("key",value);
startAtivity(i);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.