Android, using a Fragment to hold/edit complex object, accesible from any Activity

I’ll do my best to describe the problem, but I’m still very new to several concepts that I think this problem requires to be solved (namely interfaces and threads). I should preface this by saying that I’m obviously not a Comp Sci major (as you’ll see). I’ve learned as I’ve built my App, therefore my theory is terrible.

My App works as follows: I have a Workout object which is contained in an Activity, which also contains a few UI Fragments. The UI Fragments accept input from the user, Then call methods in the Activity, which then manipulate the object.

After the user finishes inputting their details, the Workout object (Which is a HashMap), gets serialized and passed to the next Activity via Bundle, then deserialized. This generally loses the order in which the user adds exercises to the Workout Object, which is important to maintain. Using LinkedHashMap doesn’t work either, as it is bugged when it comes to serialization (It deserializes as a normal HashMap, verified with Eclipse debugger). This whole process happens again when the user wants to save the Workout, as the Workout gets Bundled once again and passed to a Fragment. In other words, the Object is stored, manipulated, and accessed, in the same place as where I handle user input events. This strikes me as terrible practice.

Here’s what I think I should do:
Have one Fragment, which contains the Workout Object and runs in the background. It would also be accessible by every Activity which requires the Workout Object, and would communicate with the Fragments and activities via Interface, as follows:

                                [Background Fragment]
                                /                   
                               /                     
                      (Activity 1)                (Activity 2)
                        /                        /        
                 [UI Frag]     [UI Frag]    [UI Frag]    [UI Frag]

This solves the issue of having to pass the Workout object around like the only Joint at a Ziggi Marley concert, and the only time it will need to be serialized is when onSaveInstanceState() is called, if I’m not mistaken. This strikes me as better practice.

Does this sound like a reasonable approach for the Data flow of my App?

Although every extra detail you can give me will save me a lot of time, a Yes or No followed by a brief Why would definitely help.

This is more of a bonus question, as I’m fully willing to sort this out through the brute force method, (try things until something works), but:

Given Android’s penchant for killing background processes, what implementation would work best for maintaining and manipulating the proposed Background Fragment?

I have a hunch that having this Fragment running on a separate thread might be a good idea, but I know very little about them as of yet. Again, this Fragment needs to be accessible by more than one Activity, pretty much at any time.

If your workout object is just a collection of data, why not make it a singleton. Alternatively you could implement it as android Service and start it in your activities. I personally would not implement it as fragment, as for me fragments are more of a UI thing (even although fragments can be headless).

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật