In Android API 11+, Google has released a new class called Fragment
.
In the videos, Google suggests that whenever possible (link1, link2), we should use fragments instead of activities, but they didn't explain exactly why.
What's the purpose of fragments and some possible uses of them (other than some UI examples that can be easily be achieved by simple views/layouts)?
My question is about fragments:
- What are the purposes of using a fragment?
- What are the advantages and disadvantages of using fragments compared to using activities/views/layouts?
Bonus questions:
- Can you give some really interesting uses for fragments? Things that Google didn't mention in their videos?
- What's the best way to communicate between fragments and the activities that contain them?
- What are the most important things to remember when you use fragments? Any tips and warnings from your experience?