I know that usage of static variables on Android is quite risky, especially if you reference them to activities. However, if I have a class that extends Application (let\'s
It should be safe. Also the following note from the API docs could be relevant to you:
There is normally no need to subclass
Application
. In most situation, 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), the function to retrieve it can be given a Context which internally usesContext.getApplicationContext()
when first constructing the singleton.