mardi 13 juin 2017

Use of static member in Android Application bad?

I've stumpled upon an Android Application Class which implements the Singleton pattern and bind a static object to it.

public class App extends Application 
{
    public static BigObject myObj;

    private static App instance;

    public static App getInstance()
    {
         return instance;
    }

    @Override
    public void onCreate() {
         super.onCreate();
         instance = this;
         myObj = new BigObject(this);
    }

}

Are there any problems with this implementation, regarding performance, memory leaks or maybe Exceptions, when getInstance().myObj.something() is called form BroadcastReceiver or Service?

Aucun commentaire:

Enregistrer un commentaire