Application with the background thread

IDE: Blackberry JDE Version 4.5.0.7

Simulator: About us - Smartphone BlackBerry 2.9.0.52 Simulator

Model: BlackBerry Curve 8310 smartphone

Hi all

I have an application that, after installation on the BlackBerry must be selected in the application menu only once and will run continuously until it is uninstalled from the device. Code looks like this: -.

public final class app_name extends Application {   private BackGroundThread _thread;

   public static void main(String[] args) {        app_name app = new app_name();        app.enterEventDispatcher();    }

    public app_name() {        _thread = new BackGroundThread();         _thread.start();    }

    private class BackGroundThread extends Thread {

         public BackGroundThread() {            /***initialize parameters in constructor*****/        } 

         public void run() {             while(true) {             /*****do stuff using parameters*****/             sleep(10000);           }         }     }}

This code works well. Now, I have to add a user interface that allows the user to change some of the parameters that are used in the thread.

(1) as a first step, I have to change application to UiApplication to allow pushScreen to use. Since it's a subclass, I would have no problem with this law?

(2) to get the UI goes, my plan was to declare another class (extends screen) within app_name. What is the right way to go?

(3) parameters must be manipulated such that there is no risk of conflict of data didn't pack the thread class and the class screen try to access settings at the same time. So using the semaphore will be a good strategy?

(4) any other questions I may be brought to face or is it better to do this quite differently? I wonder if the instance of the thread class will actually be run side-by-side in the user interface and if the user interface to stop smoking will actually affect the Backgorund thread anyway. It might be better to create a completely separate application for the bit of UI that can access this application settings, but I don't know how to do this.

My apologies for the long post. Any help will be greatly appreciated.

Hello

PersistentObject is synchronized, so that it will not conflict data. You can search for "BlackBerry_Application_Developer_Guide_Volume_2" which has the details of the store persistent in the section "persistent data storage.

Thank you.

Tags: BlackBerry Developers

Similar Questions

  • How to check that my application is in the context of the background thread

    I'm listening to push into the background thread, but I want to receive the push only when the application is in the background, and then how to check that the app is in the background

    check if it is listed in http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/system/ApplicationManager.html...

  • The background thread alert does not work

    Hello

    I have read the article http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800608/... and followed the instructions to display the background thread alert. However, the alert is not displayed and IU locks (freezes). Specifically, the event of click/touch does not work, but the background thread continues to run.

    Structure of my program. The main class (with the main function) extends UiApplication. I create in the function main instance of the class that extends the Application. This class starts backgorund wire. I am missing something or making the wrong way?

    Sorry I have expired, I was going to write a long response to this.

    But in short, remember that your automatic boot process and your user interface process, both through main with different parameters and are the BlackBerry is concerned, different applications.  So it may be an Application, the other can be a UiApplication, and both can enterTheDispatcher.

    No two instances of the same Application, they are two different Applications.  They can be of different instances of the same Application class, but it is a special case.  It depends on what you create in the main routine.

    You can play a merry dance with such things.  For example, having a UiApplication be started by the automatic boot process, and then the boot gui process can find it and just put in the foreground, rather than creating a new UiApplication.

    Generally however people create a request and a UiApplication.  The problem with the use of these different applications, is that things like static are not shared.  Therefore, use something like RuntimeStore to share data.  It is a pain and something that if I can avoid.

    It is perfectly possible to have a UiApplication, which starts when the device starts, runs Background Threads that are working in a network and is bought in the foreground by clicking on an icon.  Code is more complicated, but not much.  And you must have complicated the code when you run the network Threads background to deal with the unit off power and then power anyway.

    Hope that clarifies somethings.

  • complete execution while the background thread runs

    After the passage of TestStand 4.1 in 2012, I see an interesting problem.

    I start a MainSequence via the SinglePass execution entry point using the parallel model. In ProcessSetup (in the execution of N), I start a background thread that performs certain tasks for viewing. Then the model passes by "Initialize TestSockets" and starts my MainSequence (in year N + 1).

    While the MainSequence is running, run N hangs in ParallelModel.seq > Single Pass, step "Wait for TestSockets", as it should. Usually, when the MainSequence is over, puts an end to execution and execution N goes to the next step "Check to terminate" and some time later, it passes through ProcessCleanup - where I'd send my background thread notification to stop.

    It works as long as I do not start the background thread. But when this thread is running, the execution of N + 1 never leaves the MainSequence. I arrive at a breakpoint at the end of MainSequence, ahead, and then all executions are happily showing a green light and continue to operate on. So running N never leaves "Waiting for TestSockets" and never reaches ProcessCleanup, so my son does not receive the signal of endpoint etc.

    But I distinctly remember that it worked in TestStand 4.1, and anyway, I don't understand this. Why, a background, started in the execution of N, thread prevents the execution of N + 1 to terminate?

    Concerning

    Peter

    "When execution starts a sequence in a new thread (not waiting for the thread to finish at the end of the sequence), should take care at the end of his MainSequence wire in order to put an end to herself in order for execution to terminate?"

    What do you mean by terminate? Process templates are not normally completed executions. Do you mean, "all discussions in an execution must complete before the end of the execution?"? If so, then the answer is Yes.

    I'm not completely your explanations above. I'm not sure what you mean by signs, but I think you're misunderstanding what terminate means in TestStand. Termination occurs only when a user explicitly requests a run to finish (e.g. finish all) or your sequence has an action to complete or by program initiates a terminate. Without endpoint explicit that past, executions normally end when all threads are finished executing. If you are spawning runs and new threads, you must come up with a mechanism to let them know when they have to leave. I do NOT recommend relying on or using termination for this. Termination is as abandoned (but with a cleaning), it is not intended to be something that happens in the normal flow of execution. There are several ways to tell your worker when all discussions. Perhaps this posting you are referring to is a way. You can also use a notification teststand step, or a Boolean value in reference parameter.

    Hope this helps to clear things up,

    -Doug

  • Best practices for the application in the background

    Hello

    I would like to put an application in the background. Right now, I'm this problem by generating a key event «END».

    However, with this method I have to request a change of permissions. Is there a better way to do this without requiring a change in permissions application?

                  KeyCodeEvent keyEnd = new EventInjector.KeyCodeEvent(KeyCodeEvent.KEY_DOWN, (char) Keypad.KEY_END, 0);
                    keyEnd.post();
    

    Thank you

    Thanks for the reply.

    . popScreen() is not the case, but I found that UiApplication.requestBackground () will do.

    Thank you

  • How to refresh uicomponents in the background thread?

    12.1.3 Jdev

    Hello, how do I update a component in the background thread?

    I have a utils that refresh method

    {} public void listener (ActionEvent event)

    refreshComp ('pb1');

    } / / This is the refresh

    {} public void listener (ActionEvent event)

    R runnable = new Runnable() {}

    @Override

    public void run() {}

    refreshComp ('pb1'); nullpointer

    }

    };

    Test thread = new Thread (r);

    test. Start();

    } / / not a refresh

    Method to utils:

    FacesContext.getCur... addPartialTarget (JSFUtils.findInRoot (id))

    No, there is not.

    This is the web application, so there are significant differences comparing to desktop applications and things must be implemented in a different way.

    Dario

  • I want to develop an application with the Ribbon UI by using a 3rd party control

    I want to develop an application with the user interface of the Ribbon using a 3rd party control, that I have to get a license from Microsoft? How?

    original title: license of the Ribbon user interface

    I want to develop an application with the user interface of the Ribbon using a 3rd party control, that I have to get a license from Microsoft? How?

    The only a link I found on this page does not (http://msdn.microsoft.com/en-US/office/aa973809).
  • Run the application in the background and receive updates of geolocation

    Is it possible to run an application in the background (for example all doing other things such as the use of browser, mail, etc) and always receive updates HTML5 geolocation?

    If you make your application in the "background" and do not close, the watchPosition should go on the provision of data within your App App in the background means you open the app and ample bottom to somehow minimize, for example. to open another app or something like that. As long as he remains upwards in the list of open applications it should "look at the position.

  • Application with the same icon

    A colleague dev come to share a link with me for a new application in BBW, who is not only a cheap copy of my own app, but also uses the same icon (my app was originally released a year ago).

    Now, this icon is not my creation, but as a free resource, it can be used under the license SET (credit to the author).
    While I allow it, that atm BlackBerry is not interested in this license all, always the question here - is it really so easy to get the approval of an application with the same icon? And do I (I) anything can do with it?

    Hi Ksantor,

    First of all, if the app is really a copy of your choice, you can report a violation of the right of author or brand.

    http://us.BlackBerry.com/legal/violations.html

    Regarding the icon, if it's open source it would be very difficult to refuse a request for this reason.

    For any request, there must be reasonable doubt, followed by a cause just to do this.

    powerfully.

    Bryan Van Engelen

    BlackBerry World

  • How to run my application in the background?

    Hi all

    I designed a UI screen to play a song.

    And on click of a button, I want the opportunity to go to my application in the background. Such as screen not updated, but the song continues to play.

    Thank you

    Mudassir

    tried the method requestBackground to put your application in the background?

  • How can I open my application? I loaded the Premiere Pro application with the trail period, but I don't know how to open it

    1.png

    Hello!

    I loaded the Premiere Pro application with the trail period, but I don't know how to open it

    Only 4 CS version is compatible with the 32-bit computer.

    As you had it installed 64-bit on 32-bit computers application, it is not recognizing the app and so do not register among menu start because it is not compatible.

  • Flash CS6 does not not create an .app file when I output as application with the embedded runtime

    I'm looking to create an application with the embedded runtime, but the process keeps failing without raising an error. More precisely: in settings of the Air, I select output as follows: Application with the runtime shipped. When I build this way, Flash tells me that he created the Telepath tactical - Steam.app...

    AIR building error.png

    .. .but no never .app file really does appear in the folder:

    Files Created.png

    This happens regardless of what I included in the library path and default binding settings. (When I say that it out as follows: Windows install, on the other hand, the appropriate exe file opens without problems.)

    I use Flash Professional CS6 v. 12.0.0.481 on Windows 7, 64-bit.

    So, I found this one: this problem was caused by an old .fla (original created in Flash CS4 or something like that) that had been converted over time to be compatible CS6. Recreate the .fla from scratch in CS6, corrected the problem.

  • How can I use a vector image to stretch with the background in Muse master pages?

    How can I use a vector image to stretch with the background in Muse master pages?

    Click on the 'Fill' text not the drop-down arrow.

  • Merge a layer with the background

    Is it possible to merge a layer with the background? I mean, suppose that the background does not yet exist and I have a series of layers on top of this transparent background. How can I go on the fusion of one or more of these layers with the background without flatten the whole image?

    to convert a normal layer into a background layer, you will need to select and go to the layer-> New-> layer bottom. As far as I know, this is the only place where you can do. If you want to do a bottom layer of multiple layers, you must select the layer and go first to layer-> layer blending to merge the layers into a single layer

  • Multiple instances of Application when you use the background thread

    Hi all

    I recently added a background thread in an application that is launched from an other point of entry. This background thread will constantly (every X seconds) carry out checks of RMS and compares the timestamps. When recalcitrant, he sends a notification to the user who launches the application when clicked. The problem is...

    When the user clicks on the notification, it will open the application normally (with the icon and everything), but it also opens a second instance that does not have an icon. I have concluded that the code that actually launches the request isn't the culprit (because if I take out, it nevertheless opens the second instance). This makes me think that it has something to do with the ApplicationDescriptor.

    My notification Manager has this line:

    ApplicationDescriptor appDescriptor = new ApplicationDescriptor (ApplicationDescriptor.currentApplicationDescriptor (), application name, new String [] {});

    If I change this to only return the currentApplicationDescriptor() or add the arguments in the array of strings, notifications do not work.

    Can anyone think of a reason why this is happening?

    I solved the problem I had.

    In the end, I ended up changing this code:

    final ApplicationDescriptor mainDescription = ApplicationDescriptor.currentApplicationDescriptor ();
    final ApplicationDescriptor appDescriptor = new ApplicationDescriptor (mainDescription, application_name, new String [] {});

    TO:

    moduleHandle int = CodeModuleManager.getModuleHandle (APPLICATION_NAME);
    ApplicationDescriptor mainDescriptor;

    If (moduleHandle! = 0)
    {
    ApplicationDescriptor apDes [] = CodeModuleManager.getApplicationDescriptors (moduleHandle);
    apDes = mainDescriptor [0];

    ApplicationMessageFolderRegistry folderReg = ApplicationMessageFolderRegistry.getInstance ();

    If (folderReg.getApplicationFolder (NotificationManager.INBOX_FOLDER_ID) == null) {}
    notificationManager.init (folderReg, mainDescriptor);
    }
    }

    Instead of using the currentApplicationDescriptor(), I was referencing the module of the application itself using the CoreModuleManager. My init method takes in the ApplicationDescriptor and use it for everything.

    Thanks to all who have any time to read my post!

Maybe you are looking for