My recommendation, as a rule, is to implement singletones as usual. Ignore Android and just do the usual thing like this:
class Singleton {
static Singleton sInstance;
static Singleton getInstance() {
if (sInstance == null) {
sInstance = new Singleton();
}
return sInstance;
}
}
Singleton.getInstance() . , . , ( ), , , , (, , ) . , , - .
, singleton:
class Singleton {
private final Context mContext;
static Singleton sInstance;
static Singleton getInstance(Context context) {
if (sInstance == null) {
sInstance = new Singleton(context);
}
return sInstance;
}
private Singleton(Context context) {
mContext = context.getApplicationContext();
}
}