I have a singleton GameStateManager that I want to have for all of my actions. In particular, I want him to listen for events triggered using the EventManager using the application context and not a separate activity context.
GameStateManager is tagged with singleton annotation
I tried to enter GameStateManager during Application.OnCreate (sorry, I typed the fragment from memory below, but was not copied and pasted, so it may be incorrect)
public void OnCreate(){ GameStateManager gameStateManager = RoboGuice.InjectMembers(this.getApplicationContext(), new GameStateManager()) }
I thought that the GameStateManager instance would be built with the application context, and since it would be annotated since the singleton would be available later with the application context. I noticed that when I put the GameStateManager into action, I actually got a new singleton tied to the activity context. So basically I have 2 singleton :)
Any ideas on how to have a true "singleton" that is related to the application context?
Thanks!
source share