简体   繁体   中英

Data passing between fragment activity to another activity

I want to send my location(address) from my fragment activity to another activity and show the address there. I tried for last couple days but not failed every time. please guide me.

Use Intent to pass data from one activity to another

Intent myIntent = new Intent(FirstActivity.java,SecondActivity.class);
myIntent.putExtra("data","**** Your data *****");
startActivity(myIntent);

If you want to pass user derfined Object from one activity to another then you have to implement Serilizable or Parcelable

Check the following links for how to use Serilizable

link1 & link2

use getActivity() to send data into other activity

Intent myIntent = new Intent(getActivity(),SecondActivity.class);
myIntent.putExtra("key","**** Your data *****");
getActivity().startActivity(myIntent);

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM