Category Archives: Android

What is Application class good for?

The Application class is the base class of Android application. It is the first class that is initialized when the app is started. Therefore you can initialize here everything that needs to be ready when an activity or other application component is started.

When to override Application class?

Application class doesn’t have to be overridden all the time. I presume most of simple apps can use default Application class implementation without problems. Android documentation states that

There is normally no need to subclass Application. In most situations, static singletons can provide the same functionality in a more modular way. If your singleton needs a global context (for example to register broadcast receivers), include Context.getApplicationContext() as a Context argument when invoking your singleton’s getInstance() method.

Main reasons to override Application class are following:
• Getting access to the Application Context
• Global initialization
• Getting access to global methods and data
Continue reading