Created
November 5, 2015 23:06
-
-
Save weslley39/a4685629e43f4b55e9f0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyApp extends Application { | |
private MyStateManager myStateManager = new MyStateManager(); | |
public MyStateManager getStateManager(){ | |
return myStateManager ; | |
} | |
} | |
class MyStateManager { | |
MyStateManager() { | |
/* this should be fast */ | |
} | |
String getState() { | |
/* if necessary, perform blocking calls here */ | |
/* make sure to deal with any multithreading/synchronicity issues */ | |
... | |
return state; | |
} | |
} | |
class Blah extends Activity { | |
@Override | |
public void onCreate(Bundle b){ | |
... | |
MyStateManager stateManager = ((MyApp)getApplicationContext()).getStateManager(); | |
String state = stateManager.getState(); | |
... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment