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.

Tags: BlackBerry Developers

Similar Questions

  • 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.

  • Make a new instance of a symbol existing (video clip or graphic) using AS3

    I want to make a new instance of an existing design (video clip or graphic) when an object hits the side of the stage. I have the code to see if he hit the side of the stage, I just need to know how to make a new instance and bring up where the head-butted. I also want to be able to have several of these instances on the screen. Thank you in advance, I'm sure it's a fundamental thing, I'm just really new to Flash, then Yes.

    First create the symbol as a movieclip.  Then right click on the object in the library and select the link option.  In the Panel that opens select the export for actionscript option and then assign a class name for the symbol... say you name ImageMC (caps are usually used to begin class names).  Flash will provide an indication that he cannot find a class and it will create a when you compile.

    To add a new instance of the symbol to the stage you use...

    var imgMC:ImageMC = new ImageMC();

    imgMC.x =? ;

    imgMC.y =? ;

    addChild (imgMC);

    where x and y values (?) will be established based on all the information available to you about where the ball was when he hit the wall.

  • How to make the object again during the camera movement

    How to make an object are still on a table or a surface while the camera moves?

    I think that to use the path of motion usually but the problem is theres not really a point in the clip that follows well but I know of that other methods are out there... I don't know their

    Keyframe manually there.

    Mylenium

  • How to export a PDF file to make nonprinting objects show but don't print not AND hyperlinks on the top of the page work at the same time?

    Firstly - I work in InDesign CC 2015.

    My problem is, I had this 10 page document, which, on every page, shows an object that must be in PDF format - but do not print. I made this object into a button and unchecked "Printable". On top of this object, I made 10 hyperlinks (separate layer) that point to the page 1-10.

    When you export the document and I use the interactive PDF format , works ' show nonprinting object but do not print ' well, BUT hyperlinks don't. If I uncheck the "layer of nonprinting objects" in the file PDF, then hyperlinks work, but the problem now is that the nonprinting objects are invisible...

    When you export the document and I use a PDF to print the "unprintable object show but do not print" does not work BUT the hyperlinks don't...

    I put hyperlinks to post a link to pages and also tried the link to the anchor text. No difference.

    So my question is: How to export a PDF file to make nonprinting objects show but don't print not AND hyperlinks on the top of the page work at the same time?

    Thank you

    Mette from Denmark

    I swapped my links to the buttons - AND NOW IT WORKS; (o)

  • How to make an object to rotate when it moves up and down or left and right of the key to the other?

    How to make an object to rotate when it moves up and down or left and right of the key to the other?

    Just animate the rotation property, you animate the position property of the same way.  Very easy.

  • How to make an object follow the mouseX when clicked on

    How to make an object follow the mouseX if clicked? Help, please.

    You should think it through - your code does not match your very simple explanation of what you say, it should do so, and it should... click an element and follow the mouse.

    A game loop (ENTER_FRAME) could work, but in this case it wastes unnecessary treatment if the mouse does not move.  And in your code example, it does not expect the clicks.

    Use a MOUSE_MOVE instead of an ENTER_FRAME event listener.  Inside of the event by clicking on the handler function is where you must be defined the MOUSE_MOVE listener.  The MOUSE_MOVE listener Manager is where you assign rock1Cnt.x = mouseX.

    public void Main (): void {}

    rock1Cnt.addEventListener (MouseEvent.CLICK, mouseClickHandler);

    }

    private void mouseClickHandler(e:MouseEvent):void {}

    stage.addEventListener (Event.MOUSE_MOVE, followMouse);

    }

    private void followMouse(e:MouseEvent):void {}

    rock1Cnt.x = mouseX

    }

  • How to make an object on the master always appear in front on my pages?

    I can't seem to find a way to make an object on my master to always appear in front on my pages. I watched a video on lynda.com muse essentials and it says to select the master then select the object, then go to the tab object in the menu and select move to which I did and it just shows a greyed out layer1, on video, he showed moveto > master forefront

    Thank you

    Morgan

    Refer to a similar thread here - http://forums.adobe.com/message/5581528.

    You just need to move the content of your master page to the top layer of most in the layers panel. And the content of the pages of content in the other layers to be able to manage easily. This shoud keep the contents of the master page at the top.

    The option "move to" is abandoned since we launched a workflow overall better to arrange the objects using layers - http://helpx.adobe.com/muse/tutorials/layers-muse.html.

    Thank you

    Vinayak

  • How to make an object out of the screen?

    Hello everyone!

    I create a game introduction with Flash pro CS6 and here is my problem.

    I want an object in my animation to exit the screen, but I don't know how to do it.

    Is there for example, that a way of defined work area, so that when I do something out of this area, it does not appear in my final animation (regardless of the format, .avi, .mov, spritesheets...) or may be "cut" (if I make my object inside the arear half-and-half work outside)?

    Is there another way to do this?

    Thank you!

    With the help of a mask can be a way.

  • How can I make java objects in a schema

    Hello.. good afternoon everyone...

    How can I make java objects from a database schema?

    Assume that the credentials are scott/tiger@db1

    One other thing is that... I do cmd (command prompt) because there is no developer plsql or sqldeveloper installed in the machine.

    PLSS help... Thanks in advance...

    Hello
    That's ok. This run just to try

    DROP JAVA SOURCE "javaclass1";

    Kind regards
    Simma...

  • Make an object blink or flash?

    Is there a way to make an object blink or Flash in catalyst?

    I've attached an example of a custom component I built that flashes several times after that is clicked.

    Here's how I built it:

    1. create a text

    2 convert the text to a custom component

    3. double-click on the custom component to change

    4. duplicate State

    5. change to the new State to make the appearance of "blink." I drew a yellow rect behind text

    6. double-click on the artboard to exit the editing component

    Now for the interaction

    7. Select the component, go in the interaction Panel, and choose 'Add Interaction'

    8. Select 'Sequence of playing actions' and click ok. A new action sequence appears in the timeline panel

    9. with the custom component still selected, go in the timeline panel and choose Add Action > constituent state of the value. Do this 5 times

    10. you have now several action 'State of component defined' in the timeline panel. Drag each to the right of stagger them over time

    11. Select each action "Set component State", then go to the property inspector and change which the action takes place in the State. I alternated between the custom component state2 and state1.

    Play with the attached example to see the finished product.

    Ty

  • View object instance read cache - from anywhere in the application?

    Hello. All,

    This seems to be a difficult question.

    I have a table of user information and have defined the subject entity and object view for him. I have also written a method reduceToOneUser which reduces the instance of the view object for that one line, based on user input.

    1. they are made, as in the flowchart on page of struts - config.xml, starting the flow by a loginDataPage, who passes to the dataAction_1.

    2 dataAction_1 called the reduceToOneUser, which effectively reduces the view to a single line object instance. dataAction_1 is transferred to the dataAction_2.

    3. now dataAction_2 is not just before a next node, but must send to one of SEVERAL nodes according to the values of the attributes in the instance of the view object.

    And the challenge is here. I know that the instance of the view object is there, the cache is there, but how to get the values of the attributes of the object instance in the cache of the view view when I'm in the DataAction java object? (I created the class of AuthenticationAction by double clicking on the authenticationDA icon in the page flow diagram.)


    < pre >

    package zb.view;
    to import java.util.Enumeration;
    to import javax.servlet.http.HttpServletRequest;
    Import oracle.adf.controller.struts.actions.DataAction;
    Import oracle.adf.controller.struts.actions.DataActionContext;
    Import zb.model.BillViewImpl;
    Import zb.model.ZBModuleImpl;

    SerializableAttribute public class AuthenticationAction extends DataAction
    {
    protected void findForward (DataActionContext actionContext) throws Exception
    {
    I can get the user entry OK:
    HttpServletRequest request = actionContext.getHttpServletRequest ();
    The ID of the string (String) = request.getParameter ("id");
    Chain pin (String) = request.getParameter ("pin");
    System.out.println ("ID:" + id + ", PIN:" + pin);

    Here the findForward ("toValidate") works fine and passes it to the page that the
    before toValidate points to. But in the logic of my profession, one of the attributes of the view object
    instance must meet certain conditions before the user is forwarded to this page. So I have
    need to get the attributes. - But how?
    actionContext.setActionForward (actionContext.getActionMapping () .findForward ("toValidate"));
    }
    }

    < / pre >


    I am a newbie. My approach here is appropriate? Is there a better way? It is very appreciated if someone can help out me. Thank you very much!




    Newman

    Newman,
    Now you have a configuration problem. I told you that the code comes from an earlier version of struts and may not work in your case.
    The good news is that google is your friend :-)

    This document gives an overview on your version adf data binding.

      protected void findForward(DataActionContext ctx) throws Exception {
        /*
         * "EmpService" is the name of the application module
         */
        EmpService svc = (EmpService)ctx.getBindingContext()
                                         .findDataControl("EmpServiceDataControl")
                                         .getDataProvider();
    
            // use the application module as you like ...
      }
    

    The code above show how to get the application module that is associated with a data control (from the doc above).

    Here are a few links: [link1 | http://forums.oracle.com/forums/thread.jspa?messageID=670290򣩒] and [Link2 | http://forums.oracle.com/forums/thread.jspa?messageID=719824򯯐]

    If you like some more try [this research | http://forums.oracle.com/forums/search.jspa?threadID=&q=%2Bdataaction+%2Bapplication+%2Bmodule&objID=f83&dateRange=all&userID=&numResults=15&rankBy=10001]

    Timo

  • How to implement a stack of screen "single instance".

    I'm looking to implement an application that accepts only a single instance of specific screens.  What is the best way to achieve this?  I have checked the documentation and can't seem to find anything that addresses this issue.

    The idea is similar to a singleton pattern...

    If (screen is nothing)

    {

    screen = new XYZScreen ();

    }

    return to display;

    If I already pushed my XYZScreen in the stack, using the pushScreen() method, I would like to get a handle to that instance, and they have to protest against the creation of another instance and add it also.  Also the memory problem, it makes more sense for the particular project that we are working on.

    I can't seem to find anything like "UiApplication.getUiApplication.getScreen ()" to get a reference to a particular screen already on the stack, or a 'Stack.moveScreenToTop () '.

    Suggestions, examples or links would be appreciated.

    You can use getActiveScreen() and getScreenBelow() in a loop to see if your display is already present in the stack to display.  If this is the case, then pop, and you then press it to remove it from its current position and make it visible.  If it is not on the stack, you can just push it.

    It works for you?

  • Can RuntimeStore store share some objects customed between applications?

    Hello

    I know that one application, we can use RuntimeStore to share information, including objects customed.

    What happens if sharing objects across applicatioins customed?

    Here is my scenario:

    1. two applications, app1 and app2.

    2. start app1. He puts some customed objects in RuntimeStore.

    3. run app2. It attempts to retrieve the objects of app1.

    I found this app2 cannot convert object type in type customed as defined in app1, but can convert to some standard objects BB, for example the screen.

    So is it possible to share objects between applications customed?

    You have a library that share the two applications?

    If you then set the store TIME object in the library. If you have not then you need create a library and create the class in the library for applications to use.

  • How to make the object move like mice

    I am now getting a... augmented reality project and I used flash to do this system... my system Maker use face detection and the object as a mouse cursor... means the object moves when the face moves in front of the camera... now I can do it... but I can't do this movement of the object in the frame of the flash... move only in the frame... now I would like to ask how I want to object to move out of the frame... like going inside the computer and can click on any folder (average control the computer as mouse). can someone help me?

    You cannot control the mouse of the user outside the flash scene (thankfully), and I don't think you can detect the user with their mouse off the stage with a not installed (that is to say, projector or air) flash application.

Maybe you are looking for

  • SPA10 battery and BIOS of the time lost problems

    We have 7 SPA10 laptops in our Department of the University. They are all showing the same problem when they have not been used for a week or more. The error message is: RTC battery is low or CMOS checksum is inconsistent.Press the F1 key to set Date

  • HP 20-d013w Envy TouchSmart: processor upgrade

    I am wanting to know how I would find out what CPU exact Intel my computer would be able to upgrade to. I currently have the Intel i3-3220 3.30 GHZ with a Chipset H61 and mother Larrybird-B card with a personalized card 8.7 x 9.4 in. type socket LGA

  • Check the total amount of memory consumption?

    Is there a kind of functionality or VI with the possibility to check how much the memory of LabVIEW is full? Thus, a sort of indicator that tells me I have 20% of memory remains until I get an error "Merory is full" LabVIEW? http://digital.NI.com/pub

  • The 2007 Microsoft Office Suite Service Pack 3 (SP3)

    I tried to download the update above but it fails to successfully install, any ideas please?

  • Restore points as far as the list displayed

    Hello Lorien! I did like you and Noel suggested and created another Admin account. It works very well! None of the problems errors occur in the newly created Admin account. He's got a few days of restore points for system recovery can I choose in Sys