January 2017
Beginner to intermediate
624 pages
22h 42m
English
The singleton pattern, as used in the CrimeLab, is very common in Android. Singletons get a bad rap because they can be misused in a way that makes an app hard to maintain.
Singletons are often used in Android because they outlive a single fragment or activity. A singleton will still exist across rotation and will exist as you move between activities and fragments in your application.
Singletons make a convenient owner of your model objects. Imagine a more complex CriminalIntent application that had many activities and fragments modifying crimes. When one controller modifies a crime, how would you make sure that updated crime was sent over to the other controllers? If the CrimeLab is the owner of ...
Read now
Unlock full access