addFileSystemListener without enterEventDispatcher

Hello

in this thread

http://supportforums.BlackBerry.com/T5/Java-development/http-request-at-regular-interval/TD-p/602299...

I solved my problem to create an application that runs in the background using a different entry point... That's my main (false indicates that, in the constructor, I push the main screen)

public static void main(String[] args) {
        if (args != null && args.length > 0 && "init".equals((String) args[0])) {
            Timer timer = new Timer();
            timer.schedule(new MyTimerTask(), Constants.TimerThread.INTERVAL, Constants.TimerThread.INTERVAL);
        } else {
            MyMain theApp = new MyMain(false);
            theApp.enterEventDispatcher();
        }
    }

Now, I have another problem... When I start the unit, it's when args [0] = "init", I would add a FileSystemListener to detected when the SD card is mounted. To add this port to listen I have to create an instance of my application and enterEventDispatcher on this subject. But... If I don't enterEventDispatcher the listener is called when the SD card is mounted but TimerTask is called never, on the contrary if I call not enterEventDispatcher TimerTask is called correctly but the listener is never called, so I do not know when the SD card is mounted... Can you tell me how to solve this problem?

Thanks in advance.

Kind regards

Gianni.

entereventispatcher does not return. This means that you must move all treatments before it, or in the constructor of the class.

Tags: BlackBerry Developers

Similar Questions

  • Another point of entry without rebooting

    I have an application with two possible main objects:

    • UiApplication, foreground process, we call it FG_UIApp
    • Application of the background process on the auto-run-start, we call it BG_App

    For debugging, I want to kill the BG_App by sending a FG_UIApp GlobalEvent. OK, it works perfectly. Now, the BG_App does not work. It doesn't work anymore, when I do a full reboot. But now I would like to be able to start the BG_App again without rebooting. I thought in a way like this:

    1. the user clicks on the application
    2. now check if BG_App is running, when it doesn't work, just start it
    3. for the user nothing happens, so he will again click on the app
    4. now, checking, if BG_App is running-> it works, so now we can start FG_UIApp

    To do this, I've implemented the following code. Step 1 + 2 work, but when I do the step 3 the debugger tells me, that my application is already running. Is it possible to simulate the autorun entry point without having to reboot?

    public static void main(String[] args) {
      boolean startbackground = false;
      if ( args.length > 0 && args[0].equals("autostart"))
        startbackground = true;
      else {
        boolean runtimestorevalues_are_existing = false;
        // checking some values in the runtime-store,
        // which are set by BG_App    // if these values, don't exist, we start
        // the background-process
        if (!runtimestorevalues_are_existing) startbackground = true;
      }
    
      if (startbackground){
        new BG_App().enterEventDispatcher();
      }
      else {
        new FG_UiApp().enterEventDispatcher();
      }
    }
    

    Best regards, Anil

    Hello Mark!

    After playing with the ApplicationDescriptor change, it works. The solution is here:

    /*my cod-module is called fooin my jde I have 2 projects - foo (the gui-application, called with no arguments) - fooautostart (the backgroundapp, called with the argument "autostart",     it is generally called, when the device is booting)*/public static void main(String[] args) {if ( args.length > 0 && args[0].equals("autostart")){  new BG_App().enterEventDispatcher();}else {  RuntimeStore rts = RuntimeStore.getRuntimeStore();  boolean runtimestorevalues_are_existing = false;  /*  now checking some values in the runtime-store,  which are set by BG_App; if these values, don't exist,  we have to invoke the background app in simulating the  startup-entrypoint;  */  if (!runtimestorevalues_are_existing){    try {      int modHandle = CodeModuleManager.getModuleHandle("foo");      ApplicationDescriptor[] apDes =        CodeModuleManager.getApplicationDescriptors(modHandle);      String[] args_for_descriptor = {"autostart"};      ApplicationDescriptor descriptor =        new ApplicationDescriptor (apDes[0], "fooautostart", args_for_descriptor);      ApplicationManager.getApplicationManager().runApplication(descriptor);
    
        }    catch (Exception e){      System.out.println("background start exception ex: " +         e.toString() + ": " + e.getMessage();    }  }  new FG_UiApp().enterEventDispatcher();}}
    

    Thanks and best regards to Canada.

    Anil

  • I have an ipod touch 128 GB... but I'm almost to reach its maximum.  I want to do is buy a new ipod touch 128 GB and add new music without synchronizing the entire library to it... I have 2 ipods in conjunction with other copies

    I have an ipod touch 128 GB... but I'm almost to reach its maximum.

    I want to do is buy a new ipod touch 128 GB and add new music without synchronizing the entire library to it... I have 2 ipods in conjunction with the other copies of the other.

    is this possible?

    What should I do?

    Matt

    When you get the new iPod, you can use iTunes on your computer to select and synchronize the music you want on it, in the same way that you synchronize your current iPod - your iTunes will recognize them as different devices and will remember your choice of synchronization for each, it will not (unless, for example, you restore the backup of your current on her iPod) put the same content on both.

    (I asked for your post be moved to the iPod Touch forum, where you have posted is the iPad forum use.)

  • How can I have two desktops on iCloud sync at the same time, without having duplicate files?

    Hi all

    I have two computers, a MacBook Pro and iMac. I use the new feature for Sierra macOS, which allows me to continually synchronize my office on iCloud. I welcome the Office on my iMac be synchronized on the cloud. Now, I would have the exact same office on my MacBook Pro. I tried many ways, including by dragging files to iCloud Drive on my desktop, but the synchronization does not work. If I enable syncing on my MacBook Pro, I know that I have duplicate files.

    With this method, I would like to: whenever I have add a file on my desktop iMac computer, it shows up on my MacBook Pro Office without the need for me to keep about iCloud road opening.

    Thanks for reading this.

    Ethan

    If you enable sync on the MacBook Pro, it should not be duplicates.  What makes you think it?

  • Can I pair a Apple Watch to my iPhone without a camera?

    Can I pair a Apple Watch to my Iphone without a camera (it does not)

    I see know reason why not if it's an iPhone 5 or later version.

    My only concern would be the cause of what ever the camera not only not for work could have an impact of components such as wifi and bluetooth which is necessary

  • I just new iPhone 7 & when I transfer, none of my music is available offline (purchased and apple's music program), trying to figure out how I can download it all at once, without having to enter each individual album and click the cloud

    Just got the new iPhone 7 & when I transfer iphone 6 iPhone 7, my music has arisen on the phone, but none of my music is available offline, try to understand how I can download all at once for use offline, without having to enter each individual album and click the cloud.  I have a lot of music on my phone, would take me forever to individually download each album one by one for offline use.

    I have both bought albums/songs itunes and also many of the monthly music apple package.  In any case for all it all at once?

    Hello

    You must use the same identifier apple

    Go down homepage itunes page where it says more about this music bought to display

    And download

    For music apple if its does not sign of apple ID then sign.

    See you soon

    Brian

  • is it possible to buy the iPhone 7 more unlocked and without a subscription which will work in Russia

    My friend is going to go to New York for the holidays of the maintains 21 October to 31 October. And I really want to buy the iPhone 7 more 128Gb it. I know that I need a free sim card or without a contract. I asked best buy about this and they said they don't sell iPhones with contracrs. Is this possible?

    Thank you.

    Apple has not announced when they will start to sell the iPhone Unlocked 7.

  • Since iOS 10.0.2 my phone is accessible without the access code

    Since iOS 10.0.2 my phone is accessible without the access code after I pressed the sleep button. Press the home key several times my phone opens. As a first step, it is that he fell asleep in itself not when I used the sleep button but now even after skeep button I can access my phone without the password.

    the rear power and apple support site are not easy to use to report the problem.

    Have you tried to set up your password again in the settings?

  • You can change the tempo without affecting/stretch automatically audio?

    My workflow...

    import an instrumental, then add a tempo meter to detect the tempo... can change the tempo of the project... but OOPS, that extends the audio file... How can I change the tempo without changing the audio file? Thank you!

    Region selected: in the region Inspector, uncheck 'follow Tempo and Pitch '.

    This will separate your audio region of tempo changes.

  • Does anyone know how to turn off this setting when your phone is at a certain angle turns on without you pressing the button side feed or House? Please if you know tell me!

    Does anyone know how to turn off this setting when your phone is at a certain angle turns on without you pressing the button side feed or House? Please if you know tell me!

    Settings > display and brightness > raise to Wake

  • How can I access Siri on my iMac without using the icon?

    How can I access Siri on my iMac without using the icon?  Can I say "Hey Siri"?

    There is no option "Hey Siri" on a Mac because they do not have the necessary pickups. You must use the icon in the menu bar or Dock.

  • How can I uninstall Sierra & return to El Capitan without an external hard drive or equivalent required by the instructions online?

    How can I uninstall Sierra & return to El Capitan without an external hard drive or equivalent required by the instructions online? I find too many misadventures and not happy.

    Hello

    Check out this useful tutorial: https://www.igeeksblog.com/how-to-downgrade-macos-sierra-to-mac-os-x-el-capitan/

  • Can I use Apple pay without using my fingerprints?

    I have an iphone 6 and I want to use Apple pay but there seems to be a way to get Apple to pay without using

    the fingerprint.  Is it possible to use Apple pay with an only access code?

    No, you must have active Touch ID. Is there a reason you won't do?

  • Anyone can use my phone without password afetr ois 10

    Anyone can access my phone without my password after update to 10 months

    You have a question?

  • How to get the Pages to print postcards correspondence without borders/maps?

    I have Pages 5.6.2 and I'm unable to print postcards correspondence without borders/cards. I have the margins are set to 0 and each adjustment in the format I can think.  What I'm missing!  Is there a simple fix or is this not possible?  (I was able to do this in Publisher before moving on to my Macbook Pro - so I know this isn't my printer).  I'm extremely frustrated - thanks for your help.

    Did you install the latest printer driver for your printer and selected in your printer dialog?

    Postcards and cards being generally smaller than the usual printed sheet, they are usually implemented in multiple on a page, so what you print on and how they are arranged on the page?

    Peter

Maybe you are looking for

  • It is an adware?

    Hi, so I just bought my MacBook yesterday. This is the first time I use the Apple product so I'm still unfamiliar with it. Somehow, I got adware which always opens a new tab to ps4ux.com when I open Safari and when he opened the ps4ux.com for the new

  • Stop button does not reset LabView?

    Hello I did this VI (attached to this message), but whenever I have to use "continuous run", it seems that this gives the wrong result in the façade. However, it gives correct results when I add a random check on the block diagram and delete it immed

  • Error 1068: Task Scheduler cannot start, impossible defragmentation

    I tried to defrag my sister's computer and ran into a problem.  Defragmentation wouldn't because Task Scheduler would not start.  Long story short: operating system Windows 7.  My attempts to solve the problem, there are messages that I continued to

  • Error message: since Windows was first activated on this computer, the computer hardware has changed significantly.

    original title: reactivation I just got this message: since Windows was first activated on this computer, the computer hardware has changed significantly.  Because of these changes, Windows must be re-activated in 2 days.  You want to reactivate Wind

  • is "check the message in MSN Hotmail account ' legitimate?

    I have received a request from Due to the congestion in all window Live accounts, we eliminate all accounts, Live window would close all unused accounts and unconfirmed, you are hereby asking to confirm your accounts by filling out your login informa