0

What's up. I'm creating my new app and I have problem how to send data..

I have acivity and 3 fragments in this activity. In this 3 fragments user putting some informations like his age, height, wieght etc.

And what is the best way to get this data (information from 3 fragments) and send it to parent activity or new activity. New activity will be created whem user will put all informations in all 3 fragments.

Process on image

hdost
  • 883
  • 13
  • 22
Esperanz0
  • 1,524
  • 13
  • 35

1 Answers1

0

To build on Suhas comment (stackoverflow.com/a/9346844/2244476) you can use ((Activity-A)getActivity()) inside the fragments to set the activities age, height, weight, etc then use an Intent with a Bundle from that Activity-A to the new Activity-B.

Code

Activity-A
Intent intent = new Intent()
Bundle bundle = new Bundle()
bundle.putFloat("HEIGHT", 1.6f)
...
intent.putExtras(bundle)
startActivity(intent)


Activity-B
getIntent().getExtras().getFloat("HEIGHT")
ganlaw
  • 1,303
  • 4
  • 18
  • 32
  • but I dont want start new activity before all informations will be complete.. (on all 3 fragments) Or.. meybe i Can send data from fragment 1 to fragment 2 then to fragment 3 and then startactivity.. its possible? – Esperanz0 Nov 25 '15 at 19:14