ControlledAccessException on RuntimeStore.getRuntimeStore)

We entered an uncaught exception when launching a blackberry app in the House on berries. The error seems to go away after a reset on 8700 battery, but we were getting it ramdomly on the 9000 device (each a few reboots).

The application is built on JDE4.1.0

*************************************

Event log:

Name: ControlledAccessException
GUID: 9c3cd62e3320b498
Time: August 7, 2008 11:25:06
No detail message
net_rim_cldc-12
ApplicationControl
assertIPCAllowed
0x2A87
net_rim_cldc-5
RuntimeStore

0xA165
net_rim_cldc-5
RuntimeStore
getRuntimeStore
0xA179
com_ms_rcdecommon
SMRTLED
getSMRTLED
0x3B30
com_ms_morganphone
MorganPhone
main
0 x 1322
*******************************************

code snippet:

public public static SMRTLED getSMRTLED()

{

RuntimeStore rs = RuntimeStore.getRuntimeStore ();

Sleigh SMRTLED = rs.get (SMRTLED_STORE) (SMRTLED);

if (sled is Nothing) {sleigh =

new SMRTLED (); RS.put (SMRTLED_STORE, sled);

}

carriage return ;

}

*********************************

"sled" isn't wrapped with ControlledAccess, why do we ControlledAccessException?

Thank you

June Young

ControlledAccessExpcetions can be thrown if the application attempts to do something it doesn't have permission to do.  These parameters can be seen and updated by going to Options, Advanced Options, Applications, select your application and select Edit permissions from the menu.

An application can also query and request permission changes by using the ApplicationPermissions class.

Tags: BlackBerry Developers

Similar Questions

  • Problems withdraw the application for RuntimeStore

    I have an application that listens to gps, e-mail and sms events. Because I need this application to run at startup of the bb, I used the method mentioned in many articles in kb by placing my application in the Bank to run at startup so that when my gui starts the user interface checks the runtime of the application store and proceeds accordingly. It all works perfectly. My problem comes when I need to stop the background of the GUI thread. I call shutdown in which the application stops all threads, that it is running and then I call a system.exit (0). All threads stop perfectly and closes my gui. However when I return to run the GUI with to restart the phone the waitForSingleton recover again the same background as application before having no threads running in it, and so nothing happens in the GUI (map changes). I also tried to remove the substantive application of the RuntimeStrore through .abolish. When I do cela background threads perfectly but the user interface may not start because an Exception is thrown stating that

    application running in this process... However, this is not when I call the store of runtime. Any ideas as to what I'm doing wrong?

    Thanks in advance

    if(args.length>0 && args[0].equals("gui"))
            {
    
                System.out.println("Starting GUI");
                Controller controller=waitForSingleton();
                try{
                WhereAreYouMain app=new WhereAreYouMain(controller);
                app.enterEventDispatcher();
                }
                catch(Exception e)
                {
                    System.out.println("************EXCEPTION: "+e.getMessage());
                    return;
                }
            }
            else
            {
    
                    boolean AutoStart=true;
                    if(ApplicationManager.getApplicationManager().inStartup() && AutoStart)
                    {
                        System.out.println("********************STARTING WHEREAREYOU*************************");
                    Controller app=waitForSingleton();
                    System.out.println("****************************Started WhereAreYOU**********************");
                    }
                }
            }
    
        public static Controller waitForSingleton()
        {
            RuntimeStore store=null;
            store=RuntimeStore.getRuntimeStore();
            Controller controller=null;
            controller=(Controller)store.get(AppId);
            if(controller==null)
            {
                try{
    
                store.put(AppId, new Controller());
    
                }
                catch(Exception e)
                {
                    System.out.println("Error putting app in storage"+e.getMessage());
                }
            }
            return (Controller)store.get(AppId);
        }
        public static void removeFromRuntimeStore()
        {
            RuntimeStore store=RuntimeStore.getRuntimeStore();
            store.remove(AppId);
    
        }
        public WhereAreYouMain(Controller controller)
        {
            WhereAreYouMainScreen screen=new WhereAreYouMainScreen(controller);
            controller.setMainScreen(screen);
            pushScreen(screen);
        }
    

    When stop you your application, you also have to remove all listeners?  If one of them has a reference, your application will be not eligible for garbage collection and it will remain.

    I understand that this approach (to put the application in RuntimeStore) is actually used in some articles in the KB, but I wouldn't recommend it.

    Instead, I would say put you a small 'data only' RuntimeStore object, call this myRuntimeStore object.  I - this so that you can set a reference to your UiApplication in this document, for example. Have a myRuntimeStore.setMyApp (.) method.  Now your audience can get your app if they want, using myRuntimeStore.getMyApp ().  More importantly, you can erase it and make sure that your application will.  You may encode your listeners to do nothing if your application is not present.

    However, I would like to recommend more than you do not actually store references to your application.  If you need something to initiate treatment in your application process, use a global event.  This beautifully isolates your application of your listeners.

  • How init RuntimeStore

    Hey. At last while an error crops up... If it is possible that the RuntimeStore is null, how do you proceed?

             if (_instance == null) {   // If it is still null, i.e. null in the RuntimeStore
    
                GlobalOnlyResetTimer singleton = new GlobalOnlyResetTimer();
    
                RuntimeStore.getRuntimeStore().put(GUID, singleton);
                _instance = singleton;
             }      // inner if
    

    Did you check that it is exactly the first time you have run your application? Wipe clean or reset the device Simulator? Checked to see if the problem will reappear with a different GUID?

  • UiApplication - implementation RuntimeStore vs make Singleton object / Instance

    Hi all

    I ran into a lot of trouble with putting the UiApplication instance in the RuntimeStore for later retrieval of etc. other entry points.  I used the code of this resource (http://supportforums.blackberry.com/t5/Java-Development/Make-a-running-UI-application-go-to-the-back...)

    //register the alternate on first run
    RuntimeStore appReg = RuntimeStore.getRuntimeStore();
    synchronized(appReg){
       if (appReg.get(ID) == null) {
           appReg.put(ID, new Application(...));
       }
       Application MyApp = (Application)appReg.waitFor(ID);
       //then you have the app MyApp... return it or whatever
    }
    
    //check to see if the app exists, if it does, bring it to the foreground ...RuntimeStore appReg = RuntimeStore.getRuntimeStore();synchronized(appReg){   if (appReg.get(ID) != null){       Application MyApp = (Application)appReg.waitFor(ID);       MyApp.requestForground();   }}
    

    but UiApplication.getUiApplicationInstance (); Returns IllegalStateException.

    I have posted this before and have read that I might be better to create a Singleton instance of my UiApplication - can I get some advice about how to achieve?  The code I think I should reference is:

    import net.rim.device.api.system.*;
    
    class MySingleton {
       private static MySingleton _instance;
       private static final long GUID = 0xab4dd61c5d004c18L;
    
       // constructor
       MySingleton() {}
    
       public static MySingleton getInstance() {
          if (_instance == null) {
             _instance = (MySingleton)RuntimeStore.getRuntimeStore().get(GUID);
          if (_instance == null) {
    
             MySingleton singleton = new MySingleton();
    
             RuntimeStore.getRuntimeStore().put(GUID, singleton);
             _instance = singleton;
             }
          }
    
          return _instance;
    
       }
    }
    

    Thanks in advance for any help.

    Sorry, I have not looked at your code in detail.  Simon and I wanted to understand what your application was trying to do, rather than how he did.

    What you have described so far, there is no need to put your UiApplication in RuntimeStore.  Or do you need an AlternateEntry.

    So let us try to see if we can get your app working the way you want without steps.  I'm not saying that we will succeed, but trying, we and you will understand better opportunities.

    But note that this is only my opinion and here's how I would implement what you're trying to do, with a single application. I could be missing something.

    Let's start with the listeners.

    Some listeners require a current request - for example SystemListener.  Some are not, for example telephone headsets.  Treatment is kept on a warm reboot - for example, most of the non networking Threads will be suspended and restarted.  Some are not, for example, the ApplicationMenuItems are deleted.

    Assume that at least one of your listeners requires an Application.  In general, I do not use an Application, because I use SystemListener so that I can terminate my treatment in extinction and restart under power.  Which means that you must have an Application that is started automatically.

    Now, you also want to have an icon.  Since an icon is supposed to start a UiApplication, then let us do your started automatically asks a UiApplication.  To do this, you really push a screen, but it can also "requestBackground()", so that it does not actually appear in the autostart.

    The complication here is that some of this treatment actually impossible in the early stages of implementation service, so you need to check for

    ApplicationManager... inStartUp)

    and treat them accordingly.  There is an article that describes what I think.

    So now we have one started automatically UiApplication, who listens to the system start and stop and everything stops at the stop and everything begins to start.

    Now, when you click the icon, you will not actually start your application, you're just before an existing UiApplication.

    I think that so far we have matching your needs with one exception.  What happens if you want to restart your Application?

    We have already described code that stops the processing of your request - we will work this in extinction.  You just need to run that and then do a system.exit().  Now, when your hand is called, the next time that the user clicks on the icon, it will be started just as if it was during the auto-start and will go through the same initialization.  The trick is this time, you don't want to do the requestBackground.

    Here is the key.

    (1) an initialization routine that adds the headphones and starts the other treatment.  This will also push the initial screen.

    (2) an interrupt routine that stops the treatment started in the initialization routine

    (3) main routine creates the UiApplication and adds it as a SystemListener and enterTheDisplatcher.  It checks to see if the treatment is inStartUp.

    (a) if so it horizons application - initialization will be done by the power of SystemListener.

    (b) otherwise, it executes the initialization routine

    (4) SystemListener powerUp routine that performs the initialization routine

    (5) powerOff routine SystemListener which runs the completion routine

    (6) output in your application that runs the completion routine and then call system.exit().

    I think that if you implement these parts, you will have a DBMS which deals with the way you want, with no RuntimeStorage and no AlternateEntry.

  • RuntimeStore do not store?

    Heya,

    I am trying to add an element of 'See Contact' on-screen menu, that I managed to do this successfully, but I can't get these information from contacts back from him for any reason any. I am trying to do this by making a RuntimeStore with her. Here is the run method of the MenuItem:

    public Object run(Object context) {
    
                if (context instanceof Contact) {
                    try {
                        RuntimeStore.getRuntimeStore().put( CONTACT_DATA_ID, (Contact)context );
                    } catch (IllegalArgumentException e) {
                        RuntimeStore.getRuntimeStore().replace( CONTACT_DATA_ID, (Contact)context);
                    }
    
                    Application.getApplication().requestForeground();
                }
    
                return null;
            }
    

    And here's the code tries to read:

    Contact contact = (Contact) RuntimeStore.getRuntimeStore().get(CONTACT_DATA_ID);
    
    if (contact != null) {
    System.out.println("Yay!");
    } else {
    System.out.println("This sucks...");
    }
    

    This is only an impression on the part «it sucks...» ", lol.

    Any ideas on why Miss it? It is on the simulator of Blackberry 8330 using 4.5.0

    I'm not sure that the context is not null, but it is certainly 100% Contact type. If I do something wrong in terms with the menu item please let me know = / for some reason System.out.println () prints in the run method, so he was making it difficult to test.

    Thank you ~.

    You are absolutely sure that you actually put some data in RuntimeStore.  There are a few things you say makes me very suspicious:

    "I'm not sure that the context is not null, but it is certainly 100% Contact type.".  A null object will not Contact type - your test will fail.

    "For some reason any does not print System.out.println () in the run method" - I did have a problem with that in the run method - maybe he never goes through these lines?

    I suggest you put a few breakpoints in your run method and make sure what you actually through this code, before I looked for any other problem.

  • ObjectChoiceFIeld - RuntimeStore error

    When I run my program in the Simulator, I get a "ClassCastException.  I can't understand why...

    Here is the code:

            Integer choiceOne = new Integer(0);
            if(d != null && d instanceof Hashtable) {
                Data = (Hashtable) d;
                choiceOne = (Integer)Data.get("timeposition");
            }
            int ChoiceOne = 1;
            if(choiceOne != null) {
                ChoiceOne = choiceOne.intValue();
            }
    
            /* General Display Options */
            LabelField spacer = tmtth.labelGenOne(" ");
    
            /* Time Display Options */
            String topOrBottom[] = {"Top", "Bottom"};
            positionChoice = tmtth.choiceGenTwo("Time Position Display", topOrBottom, ChoiceOne);
    

    The error occurs after that I start my Save menuitem that is the following code:

                Hashtable hs = new Hashtable();
                RuntimeStore rs = RuntimeStore.getRuntimeStore();
                TellMeTheTimeHelper tmtth = new TellMeTheTimeHelper();
                hs.put("timeposition", positionChoice);
                rs.remove(HomeScreen.MY_DATA_ID_OPTIONS);
                rs.put(HomeScreen.MY_DATA_ID_OPTIONS, hs);
                tmtth.onClose();
    

    Cast you to integer first in the code block when you pull, it forms the hash table.

    choiceOne = (Integer)Data.get("timeposition");
    
  • Use of automatic start and RuntimeStore for UIApplication... Help!

    I have a UIApplication that runs in the background and uses another entry point. The problem I have is to initialize the high device. The application will be auto-start and being thrust into the RuntimeStore (it seems anyway), and it will run in the background once the device boots-to top. But when I launch the first time through the graphical interface, trying to retrieve the existing instance of the RuntimeStore, he just return null. Thus, it instantiates the app again and place it in the RuntimeStore again, and then this will work as expected. Why the RuntimeStore put or get does not work the first time when the application auto-start? Any ideas?

    Here's the code for my main application UI, which instantiaties just my screen class:

    public class MyApp extends net.rim.device.api.ui.UiApplication
    {
        private static final long APP_ID = 0xf46f5a7867d69ff0L;
    
        public static void main(String[] args)
        {
            RuntimeStore runtimeStore = RuntimeStore.getRuntimeStore();
            if (args != null && args.length > 0 && args[0].equals("gui"))
            {
                MyApp myApp = (MyApp)runtimeStore.get(APP_ID);
                if (myApp != null)
                {
                    myApp.requestForeground();
                }
                else
                {
                    runtimeStore.put(APP_ID, new MyApp(true));
                }
            }
            else
            {
                synchronized(runtimeStore)
                {
                    runtimeStore.put(APP_ID, new MyApp(false));
                }
            }
        }
    
        public MyApp(boolean isGui)
        {
            this.pushScreen(new MyAppScreen(isGui));
            this.enterEventDispatcher();
        }
    }
    

    I think your problem might be because

    enterEventDispatcher();

    never actually "return", then the set RuntimeStore does not end.

    Try the following code that does what you want.  I put some System.out.println statements for you can follow what is happening.  Place a breakpoint on the line after either of the enterEventDispatcher() to see if it's really there.

    public class MyApp extends net.rim.device.api.ui.UiApplication {
       private static final long APP_ID = 0xf46f5a7867d69ff0L;
    
       public static void main(String[] args) {
          RuntimeStore runtimeStore = RuntimeStore.getRuntimeStore();
          MyApp _myApp;
          if (args != null && args.length > 0 && args[0].equals("gui" ) ) {
              _myApp = (MyApp)runtimeStore.get(APP_ID);
              if (_myApp != null) {
                  System.out.println("Forground" );
                  _myApp.requestForeground();
              } else {
                  System.out.println("Create" );
                  _myApp = new MyApp(true);
                  runtimeStore.put(APP_ID, _myApp);              _myApp.enterEventDispatcher();
                  System.out.println("dispatched" );
              }
          } else {
              System.out.println("Auto Start" );
              _myApp = new MyApp(false);
              synchronized(runtimeStore) {
                  runtimeStore.put(APP_ID, _myApp);
              }
              System.out.println("Added" );
             _myApp.enterEventDispatcher();
              System.out.println("dispatched" );
          }
       }
    
       public MyApp(boolean isGui) {
           this.pushScreen(new MyAppScreen(isGui));
       }
    }
    
  • Sharing RunTimeStore

    Hello

    I read in a previous post that applications can share data using the RunTimeStore API, and I'm trying to share data in my application

    between 2 different modules, however I can't do.

    I create in my main module of the RunTimeStore

    RuntimeStore appReg = RuntimeStore.getRuntimeStore();
    synchronized(appReg){
                    if (appReg.get(generalConst.GUI_ID) == null){
                            appReg.put(generalConst.GUI_ID, new guiSet());
                    }
            }
    

    and then the second module I do the following:

    RuntimeStore appReg = RuntimeStore.getRuntimeStore();
    if (appReg.get(generalConst.GUI_ID) == null) {
       appReg.put(generalConst.GUI_ID, new guiSet());
    }
    
    guiSet tmpGUISet = (guiSet)appReg.waitFor(generalConst.GUI_ID);
    

    However, I get an exception when I try 'waitFor' the RunTomeStore. Anyone has any idea why?

    Thank you.

    Yes I did, but it did not work.

    However I found a solution, I created a new library and all the RunTimeStore is managed by this library only

  • Listener GPS problem

    Hi people,

    In collaboration with 4.2.1 on the 8800 Simulator.  My application is currently composed of two separate applications, app UI to obtain/view the information and a 'replication' application that communicates with our backend. I want to be able to include location on request of the user data (in the application user interface) and once it is updated, have replication app send it to the server. I have this work especially to my satisfaction, but the following problem: when I close the application user interface, any incomplete GPS please never finished. It seems that my LocationListener is not registered, or maybe the listener Thread is killed the closure of the part of the user interface. I don't expect that the instance is stored in the runtimestore and the object that is saved as the listener is always valid. Here's how I set it up:

    App of the user interface, the following is performed from a menu, click:

                GPSUpdater gps = GPSUpdaterFactory.getGPSUpdater();            gps.getGPSData(row, GPSUpdater.CHECK_IN);
    

    Replication App: (cut a lot of independent code)

    class ReplicationManagerImpl implements LocationListener{    private GPSUpdater mGPSUpdater;
    
        ReplicationManagerImpl()    {        mGPSUpdater = GPSUpdaterFactory.getGPSUpdater();        mGPSUpdater.setListener(this);    }
    
        public void locationUpdated(LocationProvider provider, Location location)    {        mGPSUpdater.newLocationReceived(location);    }
    
        public void providerStateChanged(LocationProvider provider, int newState)    {        //Not worried about this    }}
    

    GPSUpdater:

    public class GPSUpdater{    private Vector mUpdates;    private LocationProvider mProvider;    private Location mLocation;    private LocationListener mListener;    private Boolean isAcquiring;    private int mCounter;
    
        private static final int MAX_RETRIES = 10;    public static final int CHECK_IN = 0;    public static final int CONFIRM = 1;
    
        private static class UpdateData    {        private DataRow suRow;        private int updateType;        private long timeStamp;    }
    
        GPSUpdater()    {        Criteria criteria = new Criteria();        criteria.setHorizontalAccuracy(50);        criteria.setVerticalAccuracy(50);        criteria.setCostAllowed(false);        try        {            mProvider = LocationProvider.getInstance(criteria);            if (mProvider.getState() == LocationProvider.OUT_OF_SERVICE)            {                SubsystemLog.log("GPS actions not supported", EventLogger.ALWAYS_LOG);            }        }        catch (LocationException lEx)        {            SubsystemLog.log("Error creating LocationProvider in GPSUpdater: " + lEx.getMessage(), EventLogger.ERROR);        }        mUpdates = new Vector();        mLocation = null;        isAcquiring = Boolean.FALSE;        mCounter = 0;    }
    
        public void setListener(LocationListener listener)    {        mListener = listener;    }
    
        public void getGPSData(DataRow row, int updateType)    {        long timestamp = System.currentTimeMillis();        if (((mLocation != null) && (mLocation.isValid()) && (mLocation.getTimestamp() > timestamp - 60000)) || (mProvider == null) || (mProvider.getState() == LocationProvider.OUT_OF_SERVICE))        {            UpdateRow(row, updateType, timestamp);        }        else        {            UpdateData update = new UpdateData();            update.row = row;            update.updateType = updateType;            update.timeStamp = timestamp;
    
                synchronized(mUpdates)            {                mUpdates.addElement(update);            }
    
                synchronized(isAcquiring)            {                if (!isAcquiring.booleanValue())                {                    mProvider.setLocationListener(mListener, 5, 5, -1);                    isAcquiring = Boolean.TRUE;                }            }        }    }
    
        public void newLocationReceived(Location location)    {        if ((location == null) || (!location.isValid()) && (mCounter < MAX_RETRIES))        {            mCounter++;            return;        }
    
            mCounter = 0;        mLocation = location;        SubsystemLog.log("Acquired co-ordinates: " + Double.toString(location.getQualifiedCoordinates().getLatitude()) + "," + Double.toString(location.getQualifiedCoordinates().getLongitude()), EventLogger.DEBUG_INFO);
    
            Database db = DataSystemFactory.getDataSystem().openDatabase(DBSchema.NAME);        Object syncObject = db.getSyncObject();
    
            synchronized(syncObject)        {            while (mUpdates.size() > 0)            {                UpdateData update = (UpdateData)mUpdates.elementAt(0);                UpdateRow(update.row, update.updateType, update.timeStamp);                mUpdates.removeElement(update);            }        }        db.commitAndNotify();
    
            synchronized(isAcquiring)        {            provider.setLocationListener(null, -1, -1, -1);            isAcquiring = Boolean.FALSE;        }    }
    
        private void UpdateRow(DataRow suRow, int updateType, long timeStamp)    {        //wrapper class to allow persisting double values        DBDouble latitude = new DBDouble();        DBDouble longitude = new DBDouble();
    
            if (mLocation != null && mLocation.isValid())        {            latitude.setDouble(mLocation.getQualifiedCoordinates().getLatitude());            longitude.setDouble(mLocation.getQualifiedCoordinates().getLongitude());        }        else        {            latitude.setDouble(0.0);            longitude.setDouble(0.0);        }
    
            //store data here    }
    
    }
    

    GPSUpdaterFactory:

    public abstract class GPSUpdaterFactory {    private static final long ID = ;
    
        public static final GPSUpdater getGPSUpdater()    {        Object o;        GPSUpdater gpsUpdater = null;        RuntimeStore runtimeStore = RuntimeStore.getRuntimeStore();        synchronized (runtimeStore)        {            o = runtimeStore.get(ID);            if (o != null)            {                if (o instanceof GPSUpdater)                {                    gpsUpdater = (GPSUpdater)o;                }            }            if (gpsUpdater == null)            {                gpsUpdater = new GPSUpdater();                runtimeStore.put(ID, gpsUpdater);            }        }        return gpsUpdater;            }}
    

    Any suggestions are greatly appreciated.

    Thank you

    Mike

    Notice that the menu close item also called System.exit.

    In this case the application would stop receiving updates following the call of output.  To work around this problem, you can call Application.requestBackground.  This moves the application in the background, where it can continue to operate.  Once you have your final fix application can call System.exit to close itself.

  • Add and delete a Listner folder to store

    I'm developing an application with the api Folderlistner... I can get all mails from my store, I had 2 problems in my application

    I can't quit smoking folderlistner. use

    removelistner method when calling exit (system.exit) after tat my request for treatment of all email for example my request to delete all emails from my store. How to delete store folderlistner

    When restart it my application processing emails once more, I want to say 2 headphones, working at the same time not only 2

    For each restart another a listner shoud added

    How can I solve this problem?

    the addition of listner

    mystore= session.getStore();
    mystore.addFolderListener(this);
    

    in removeing llistner, while calling system.exit (0)

    mystore.removeFolderListener(this);
    mystore=null;
    

    To create an instance of singleton you need not another entry point. I was referrring you to this part of the code and not the application complete. Just set up the next part in your application and no need for alternate entry point parameters.

    private FolderListenerGUI folderListenerGUI = null;
    
      //Long value: com.samples.folderListener
    
      public static final long RTSID_MY_APP = 0x7451402f595f81a5L;
    
      public FolderListenerApp() 
    
      {
    
        try
    
        {
    
          //Get the store from the default instance.
    
          Store store = Session.getDefaultInstance().getStore();
    
          //Add the folder listener to the store.
    
          store.addFolderListener(this);
    
        }
    
        catch (Exception e)
    
        {
    
          System.out.println(e.toString());
    
        }
    
      }
    
      //Returns an instance of the running FolderListenerApp.
    
      public static FolderListenerApp waitForSingleton()
    
      {
    
        //Ensure this is a singleton instance.
    
        //Open the RuntimeStore.
    
        RuntimeStore store = RuntimeStore.getRuntimeStore();
    
        //Obtain the reference of FolderListenerApp.
    
        Object obj = store.get(RTSID_MY_APP);
    
        //If obj is null, there is no current reference
    
        //to FolderListenerApp. Start a new instance
    
        // of FolderListenerApp if one is not running.
    
        if (obj == null)
    
        {
    
          //Store a reference to this instance in the RuntimeStore.
    
          store.put(RTSID_MY_APP, new FolderListenerApp());
    
          return (FolderListenerApp)store.get(RTSID_MY_APP);
    
        } else
    
        {
    
          return (FolderListenerApp)obj;
    
        }
    
      }
    

    Kind regards

    yosoh

  • Periodic controls

    I try to have the blackberry vibrates and increment the counter icon every minute or so. I tried the following code and it vibrates periodically but does not increment the count of the icon on the top of the home screen. The second block of code is supposed to be the singleton who must keep track of the count variable and share it. Does anyone know why the County grows not here? ScheduleVibrate is called the principal.

    static MyAppIndicator SV = MyAppIndicator.getInstance();                  // notification icon on home screen
        private static void scheduleVibrate()                                        // schedule to vibrate
        {
            IconManager iconManager = IconManager.getInstance();   //icon manager keeps track of icon
                int increment = iconManager.getCount();                         // count
    
            iconManager.setCount(increment + 1);                            //this SHOULD change the count
            SV._indicator.setVisible(true);
            SV._indicator.setValue(iconManager.getCount());
            Alert.startVibrate(2550); 
    
            ApplicationDescriptor current = ApplicationDescriptor.currentApplicationDescriptor();
            current.setPowerOnBehavior(ApplicationDescriptor.DO_NOT_POWER_ON);
            ApplicationManager manger = ApplicationManager.getApplicationManager();
            manger.scheduleApplication(current,System.currentTimeMillis()+1000,true);
        }
    

    The code for the singleton of icon Manager is:

    public class IconManager {
        private static IconManager _instance;
        private static final long GUID = 0xab4dd61c5d004c18L;
        private static int iconCount = 0;
        // constructor
        private IconManager() {
        }
        public static IconManager getInstance() {
            if (_instance == null) {
                _instance = (IconManager) RuntimeStore.getRuntimeStore().get(GUID);
                if (_instance == null) {
                    IconManager singleton = new IconManager();
                    RuntimeStore.getRuntimeStore().put(GUID, singleton); //changed this
                    _instance = singleton;
                }
            }
            return _instance;
        }
    
        public static int getCount() {
            return iconCount;
        }
        public static void setCount(int count) {
            iconCount = count;
        }
    }
    

    Remove static electricity

    private static int iconCount = 0;

    public static int getCount() {}

    and

    {} public static void more (int count)

    and it will work for you.

    Must say that restart your application to run the lines seems you a real stretch.  What about just having a background and a timer application?  And don't forget that the Application restarts will not take place immediately and may be delayed up to 1 minute, I think that according to the documentation.

  • Sharing of Variables

    I need to share a common variable in my application between different ports of entry. The variable is a simple number that keeps track of the amount of notifications on the homescreen icon. Updates every time that the application background regular increments the count variable that is then used by setValue (count) to view it. The user simon_hain suggested using the singleton and runtimestore approach. I was looking around this method and found a snippet of user Adama:

    Integer i = new Integer(0);
    RuntimeStore.getInstance().put(ID, i);
    i.setValue(7);
    
    //On other module:
    Integer i = (Integer) RuntimeStore.getInstance().get(ID);
    

    My problem is that I still don't know how to properly use this code, I also watched

    http://docs.BlackBerry.com/en/developers/deliverables/17952/CS_creating_a_singleton_by_using_rutnime...

    but I do not know how to implement that in my code. I am trying to increment the variable iconCount which must be kept consistent vicinities of background processes and foreground (i.e. If the user checks the application, notification of alerts will be reset to 0).

    public void setVisible1(boolean visible, int count) {
        if (_indicator != null) {
            if (visible) {
                _indicator.setVisible(true);
                _indicator.setValue(++count);   //incrementing count
                UserInterface.iconCount++;      // also trying here
            } else {
                _indicator.setVisible(false);
            }
        }
    }
    

    With the help of RuntimeStore.getInstance () .put (GUID, countsIcon); in my class UserInterface creates errors probably because I use it wrong or not in the right place.

    Once again thanks for any help.

    Here is a way.

    Here's the class from the link you provided before:

    Net.rim.device.api.system import. *;

    Class MySingleton {}
    private static MySingleton _instance;
    private static final long GUID = 0xab4dd61c5d004c18L;

    constructor
    {MySingleton()}

    public static MySingleton getInstance() {}
    If (_instance == null) {}
    _instance = (MySingleton) RuntimeStore.getRuntimeStore () .get (GUID);
    If (_instance == null) {}
    Singleton MySingleton = new MySingleton();

    RuntimeStore.getRuntimeStore () .put (GUID, singleton);
    _instance = singleton;
    }
    }

    return _instance;

    }
    }

    Change this, so tjhat

    (a) there is a get and Set accessor for the variable you want.

    (b) the constructor creates an intiial value for the variable.

    Now you will use in your code

    MySingleton mysingleton = MySingleton.getInstance ();

    myIconCount mysingleton =. getIconCount();

    To change

    MySingleton mysingleton = MySingleton.getInstance ();

    mysingleton .setIconCount (myIconCount);

    Look at this, to look again at the Singleton class and review the link you rpvoided.  Yo must now understand h: to create a Unique ID for you to use, but I'm sure that you can search for it.

  • Bifurcation of Application Exception

    Hello

    I use RunTimeStore to store a reference to the instance of the application when the startup autorun entry.

    When I try to open the application from the main screen (by clicking on the icon - another entry point), I get the back reference to the RunTimeStore. Then, I'm trying to push the home screen (home screen is an instance of the class). I get an unhandled exception: no application instance.

    Please check the code below

    class UiAppSample extends UiApplication {
    
        private HomeScreen iHomeScreen; //main screen instance
        public static final long ID = 0x60ac754bc0867248L; // RuntimeStore ID
        private static App_Sender_Listener iSenderListener; // SystemListner Instance
    
        //constructor
        UiAppSample() {
               //
        }
    
        public static void main(String[] args)
        {
            //check for entry point(during autorun or normal)
    
            if ((args.length > 0) && (args[0].equals("Startup")))
            {
                //regestering the app in the store with the ID
                RuntimeStore iRTS = RuntimeStore.getRuntimeStore();
                if (iRTS.get(ID) == null)
                {
                    //
                    iRTS.put(ID,new UiAppSample());
                }
                UiAppSample iDLApp = (UiAppSample)iRTS.get(ID);
    
                iSenderListener = new App_Sender_Listener();
                iDLApp.addSystemListener(iSenderListener);
                iSenderListener.registerUI(iDLApp);
    
                //entering even dispatcher
                iDLApp.enterEventDispatcher();
            }
            else
            {
                //getting the reference from the RuntimeStore during normal entry
                if (iRTS.get(ID) == null)
                {
                    //
                    iRTS.put(ID,new DriveLink());
                }
    
                UiAppSample iDLApp = (UiAppSample)iRTS.waitFor(ID);
                iDLApp.vScreenInit(); //for screen initialization
                iDLApp.vShowHome();   //to push mainscreen
            }        
    
        }   
    
        private void vScreenInit()
        {
            //
            iHomeScreen = new HomeScreen();
        }
    
        private void vShowHome()
        {
            //
            pushScreen(iHomeScreen);
            iDL_SenderListener.StartSendThread();
        }
    }
    

    The Exception occurs in the line 'iHomeScreen = new HomeScreen();' in the 'vScreenInit' function, which is called after obtaining a reference to the RunTimeStore.

    HomeScreen is an inner class that extends screen. No error in the class. I have tested this app before the edition of start autorun. So I did not add this part of the code.

    Please help me.

    Hi Mark,

    I removed the implementation of logic runtimestore.

    I used the method ApplicationManager and postGlobalEvent to bring the background GUI in the foreground part.

    I'm now able to start the GUI part successfully since the background thread.

    For reference:

    http://supportforums.BlackBerry.com/T5/Java-development/how-to-avoid-creating-two-instances-of-the-a...

  • How to make a single instance of the application regardless of the main application and the other entry point for the application

    Hello experts,

    I explain the sceniro of my application. My request is mainly a time system as well as some other features related businesses. My app has a landing screen which is actually a custom made calendar that accumulates information captured time. There is also a time where entry screen user at will has worked time and other related information. The user has the option to run the application manually at the entrance of the time and see the reports and there the event listener to follow the events of call/SMS/e-mail that invokes the application automatically and user to the scree of time entry.

    Problem one: I used headphones to follow the events of call/SMS/e-mail. When an event is called, alternet point of entry of the application the application is running. Application then get calls time, contact information etc. and push my entry screen with pre-filled information time.

    As such, it works very well, as expected, but the problem is the number of instence that he is creating. Each track event creates a new instance of the application. I want to keep only one instance.

    Two problems: to solve this problem, I removed the other point of entry and RuntimeStore to keep the running instance of my application. This instance of the application in a way keeps in singletone as such when the listener calls the application it finds that the application is running in the background. Then she moves the application to the foreground. It works very well, I mean the application user interface called on the foreground, but he won't have to time entry screen automatically as I hope. The block of code is as follows,

    public static final long applicationID =0x8ddc44508679bd5bL;
    static NSIApplication NSIInstance=null;
    RuntimeStore runtimeStore = RuntimeStore.getRuntimeStore();
    
    if (NSIInstance != null)
                {
                    NSIInstance.requestForeground();
                }
                else
                {
                    synchronized (runtimeStore)
                    {
                        NSIInstance = (NSIApplication)runtimeStore.get(applicationID);
                                            //listener initialization
                        NSIListener.Initialze();
                    }
    
                    if (NSIInstance != null)
                    {                   NSIInstance.requestForeground();
                                        //event's info manipulation and push the time entry screen                                     NSIInstance.RUN_NSIApplication();
                    }
                    else
                    {
                        NSIInstance=NSIApplication.getInstance();
                        NSIInstance.RUN_NSIApplication();
    
                        synchronized(runtimeStore)
                        {
                            runtimeStore.put(applicationID, NSIInstance);
                        }
    
                        NSIInstance.enterEventDispatcher();
                    }
                }
    

    I expect a guideline to follow so that I can reach the expected my workflow. Thanks in advance

    I can't propose to use the runtimestore to store instances of the application, as it was used on an example RIM, he has never worked for me.

    I suggest to use a single point of entry and the automated screen using a global event or status in the runtimestore.

  • [BB 5.0] Impossible to return to the foreground

    I know similar problems have been discussed several times already, but looks like I'm still too noob to solve my problem. A problem is the following.

    I am trying to create a simple GUI application. It starts automatically, adds a special menu item in the system menu and goes to the background hidden from the list of applications. Once the user clicks on the item menu (mentioned above), the application must show the user, do something and go back to the background. I used this article as a guide.

    My code is (BTW, how I format the code here?):

    SerializableAttribute public class BackTest extends UiApplication {}

    private static final long APP_ID = 0xda989447901484c8L;

    Private boolean isHidden = true;

    Public Shared Sub main (String [] args) {}
    RuntimeStore store = RuntimeStore.getRuntimeStore ();

    BackTest PAP = null;

    If (args == null | args.length == 0) {}
    PAP = (BackTest) store.get (APP_ID);
    If (PAP! = null) {}
    theApp.setHidden (false);
    theApp.requestForeground ();
    }
    } else {}
    final BackTest app = PAP = new BackTest();
    Store.Replace (APP_ID, PAP);

    theApp.createMenuItem ();
    theApp.setHidden (true);
    theApp.invokeLater (new Runnable() {}
    public void run() {}
    app.moveToBackgroundOnStart ();
    }
    });
    theApp.enterEventDispatcher ();
    }
    }

    public BackTest() {}
    pushScreen (new BackTestScreen());
    }

    private void moveToBackgroundOnStart() {}
    ApplicationManager man = ApplicationManager.getApplicationManager ();
    KeepGoing Boolean = true;
    {while (keepGoing)}
    If (man.inStartup ()) {}
    try {}
    Thread.Sleep (500);
    } catch (Exception ex) {}
    } else {}
    this.requestBackground ();
    }
    }
    }

    protected boolean acceptsForeground() {}
    return! this.isHidden ();
    }

    protected boolean isHidden() {}
    Return isHidden;
    }

    protected void setHidden (boolean isHidden) {}
    this.isHidden = isHidden;
    }

    private void createMenuItem() {}
    placement of int = 0 x 350111;
    Element ApplicationMenuItem = new ApplicationMenuItem (investment) {}
    public String toString() {}
    return to 'Just Do It';
    }

    public Object execute (object context) {}
    try {}
    ApplicationManager.getApplicationManager (.launch ("BackTest"));
    } catch (ApplicationManagerException e) {}
    e.printStackTrace ();
    }
    Returns a null value.
    }
    };

    The ApplicationMenuItemRepository repo = ApplicationMenuItemRepository.getInstance ();
    repo.addMenuItem (ApplicationMenuItemRepository.MENUITEM_SYSTEM, item);
    }
    }

    My problem is that when I click on the menu item "Just Do It", the application does not appear. I see in the debugger, that requestForeground is called, but nothing happens after that. I tried different things, like using GlobalEventListener instead of launching the app again (which resembles the app in the background does not receive events) or by calling requestForeground directly in the menu item Manager, but nothing happens.

    What I am doing wrong?

    PS the JRE BB version is 5.0.

    Interestingly, the code seems fine for me.  Sorry don't have time to test it myself ATM - maybe later.

    There is one thing I would change:

    theApp.invokeLater (new Runnable() {}
    public void run() {}
    app.moveToBackgroundOnStart ();
    }
    });

    This in theory, runs your "pen" treatment, specifically sleep, on the thread of events.  You need not actually the bottom of the request to wait because if your application is enough to throw things on the event thread, then it can deal with the merits of the request.  Then you can just run the requestBackground

    If you have other things you plan to wait at first, then in the executable you invokeLater, start a new Thread.  Sounds a bit complicated, I know.

    I don't think that this causes you a problem in this circumstance.

    I would like that you try to move your code to the main() in the run method ApplicationMenu.  There is no problem with this code getting your instance of the application and then by running requestForeground() on it.

    If this does not help, you can do two things:

    (1) create activate(), deactivate() methods in your Application, simply d put something out of System.out when these are run - call super too of course!  See the Application section to determine what these do.

    (2) put a breakpoint in acceptsForeground() and see when it is in the order of things, it is called.  I have an idea it is actually called earlier than you expect.

Maybe you are looking for

  • Tecra M2 can't see the wireless router

    I have a Tecra M2. I see our home wireless router and all our neighbors Wi - Fi, but very often the laptop does not see our router. The only way to solve this problem at this time is to plug the Ethernet cable and change the wireless channel.He can s

  • Hooray! Sansa e260v2 not load not exit mode MSC, refuses to install the drivers...

    I have an e260v2 that I bought and used there are about 1 1/2 months. It has worked well for so long. But a couple of days, I reformatted the hard drive of my PC and things started to the South. BEFORE all the WORLD the SAID: Yes, the firmware is up

  • Acer monitor X223h & AL2216W not "detected" in Windows 7

    I've been running Windows 7 Pro. (Clean install) as a Dual boot (XP) on my Lenovo Thinkpad R60. There is a problem that I have not been able to fix & that's when I want to connect an external monitor Acer - X223h or AL2216W. Windows 7 does not detect

  • Just need to Photoshop and Illustrator

    HelloI just need Photoshop and Illustrator for my business. There's no plan with this mixture. Is there a way to subscribe to only these 2 applications and not the whole cloud?I hope someone can help.-A

  • calculation of time between two time as timestamp

    How can calculate two hour, START as the timestamp TIME in the data type, END TIME as of time also. select END_TIME-START_TIME from PROG_DLY_WORK Result+ 01:50:00.000000 000000000How can get exactly the time spent as 01:50 ? and these calculated time