January 2017
Beginner to intermediate
624 pages
22h 42m
English
Earlier in this chapter, you used the application context in the constructor of the CrimeLab.
private CrimeLab(Context context) {
mContext = context.getApplicationContext();
...
}
What makes the application context special? When should you use the application context over an activity as a context?
It is important to think about the lifetime of each of these objects. If any of your activities exist, Android will have also created an application object. Activities come and go as the user navigates through your application, but the application object will still exist. It has a much longer lifetime than any one activity.
The CrimeLab is a singleton, which means that once it is created, ...
Read now
Unlock full access