(, , ) Application . Application, . , Application ( , Context, getApplicationContext()?).
, Application , , ...
public class MyClass extends Application {
private MyObject mObject = null;
public static MyObject getMyObject() {
if (mObject == null)
mObject = new MyObject;
return mObject;
}
}
From anywhere in your code, you can simply use ...
MyClass.getMyObject();
... to get an instance of your object.
source
share