Skip to content

Instantly share code, notes, and snippets.

@shekibobo
Created June 6, 2014 18:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shekibobo/7f23a9191df1de91c442 to your computer and use it in GitHub Desktop.
Save shekibobo/7f23a9191df1de91c442 to your computer and use it in GitHub Desktop.
public class MyApp extends Application {
private static Context context;
private static ObjectGraph objectGraph;
@Override
public void onCreate() {
super.onCreate();
context = this;
buildObjectGraphAndInject();
}
public void buildObjectGraphAndInject() {
objectGraph = ObjectGraph.create(Modules.list(this));
objectGraph.inject(this);
}
public static void injectStatic(Object o) {
objectGraph.inject(o);
}
public void inject(Object o) {
objectGraph.inject(o);
}
public static MyApp get() {
return (MyApp) context.getApplicationContext();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment