Well, My answer is not specific to @Singleton of Guice , but if you want to create a class that is accessible in all your actions, then I think you should use the Android Application . (This is my personal opinion about your need)
The way to do this is to create your own subclass of android.app.Application , and then specify the class in the application tag in your manifest . Now Android will automatically instantiate this class and make it available to your entire application. You can access it from any context using the Context.getApplicationContext() method (Activity also provides the getApplication() method, which has the same effect):
class MyApp extends Application { private String myState; public String getState(){ return myState; } public void setState(String s){ myState = s; } } class Blah extends Activity { @Override public void onCreate(Bundle b){ ... MyApp appState = ((MyApp)getApplicationContext()); String state = appState.getState(); ... } }
This has the same effect as a static variable or singleton, but integrates pretty well into the existing Android platform. Note that this will not work in all processes (should your application be one of the rare ones that has several processes).
Here is a good tutorial on how to use it, Android app class extension and working with Singleton
source share