01-29-2014 05:59 AM
I have singleton class getting initalised at the start of my app.I have thread class which which listens to send SMS in it and once i get SMS in my thread class ,I am trying to use instance of singleton class and save in it which has vector in it ,but my instance is coming as null for the thread for the first time but for the second time ,it show instance of first instance created during send first time.
For the other thread which receive SMS,instance is same as which as initialised during app launch,What is mistaking i am making which cause this issue.
01-29-2014 06:07 AM
I am confident you are attempting to use a static reference to your Singleton class. In BB Java, a static instance is a Singleton within one Application COntext. So this works if you don't run any code that runs as part of another application. But you have listeners, and they will normally run in the context of the Application that you are listening too. So they do NOT see your Application's static instance, they see their own and it will not have been initialised.
Fix using a Singleton in RuntimeStore: