Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Posts: 19
Registered: ‎09-10-2012
My Carrier: BlackBerry

Accessing static variables from one application to other application

Hello Everyone,


I have created an application which runs at auto-startup and extends 'Application' class. In that application by 'set alternate entry point', i started UI application by passing 'gui' arguments.

Now I have used static variables for instantiate and execute 'timer task' in that 'Application' class and want to cancel timer in UI application.


But by accessing static variable in UI class, I get null that staic variable.


I need to start timer at auto-startup in 'Application' class. So can anyone please guide me , how can i access static variable  in UI class.


(static variable object is created in MyApplication class which extends Application

like- public static TimerDemo timer =new TimerDemo(); 

In UI class which is started from UiApplication,  I used like- MyApplication.timer ,  returns null


Thanks in advance

Please use plain text.
Posts: 19,513
Registered: ‎07-14-2008

Re: Accessing static variables from one application to other application

[ Edited ]

You can not access static values from different applications.


If you wish to share variables, put these in RuntimeStore.  Here is a useful KB article to help doing this.




Be aware that RuntimeStore is not lost when an Application terminates.  So I recommend that you clear references in RuntimeStore whenever you can to make sure that the garbage collector can free redundant Objects.


Note that an application that has two entry points is really two applications, so the two entry points do not share static variables. 

Please use plain text.