In an Android app, is there anything wrong with the following approach:
public class MyApp extends android.app.Application {
private static MyApp instan
I'm using the same approach, I suggest to write the singleton a little better:
public static MyApp getInstance() {
if (instance == null) {
synchronized (MyApp.class) {
if (instance == null) {
instance = new MyApp ();
}
}
}
return instance;
}
but I'm not using everywhere, I use getContext()
and getApplicationContext()
where I can do it!