Welcome!

Welcome to the official BlackBerry Support Community Forums.

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

inside custom component

Java Development

Reply
Developer
superdirt
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Previous instance still active

Without exiting the application, this message appears sometimes when the user selects my application's icon from the home screen. After this message appears, sometimes the device will hang and require a battery pull, and other times the application continues to run despite the error but the message will show every time I select the icon from the home screen afterwards. I understand that this error message can appear if the application exits without unregistering system registered listeners (I use many system registered listeners in this application) but the application stays open constantly. 

 

Does this mean the application is trying to open again and again each time I select the icon from the homescreen? I believe I could solve this by using RuntimeStore, but I don't recall ever seeing this behaviour before. 

 

Thanks.

 

Scott

Please use plain text.
Developer
peter_strange
Posts: 19,598
Registered: ‎07-14-2008
My Device: Not Specified

Re: Previous instance still active

Sorry I am not going to be able to shed much light on this.  But I will add my 2p worth of observations. 

 

I have seen this a lot in testing on the Simulator but not in 'production' or on a device.  The app I see it a lot in is connected to BBM and I must admit that I thought this message was related to BBM, because I seldom see it on other apps and again only when they are BBM connected.  As noted it does seem to happen when I crash off the application, but since I do nothing special on exit for BBM, I don't understand this   When it happens I can usually blame something I did.

 

Like I said, doesn't help much, but I would be very interested to know if your app uses BBM. 

Please use plain text.
Developer
superdirt
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: Previous instance still active

Thanks for the input, Peter. I am not integrating with BBM in this application.

 

It is however a PushApplication and twice the error showed up after a push was received. I wonder if the bug is related to the OS handling the push messages even though I am getting the message just fine. The last time it happened I attached the debugger and no exceptions were thrown, but it didn't occur to me to step through the public static void main method with the debugger.

 

Scott

Please use plain text.
Developer
simon_hain
Posts: 15,846
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Previous instance still active

As far as i know this relates to issues cleaning up after exiting a program.
If you use any listeners and do not deregister them properly there may be non-shallow links keeping parts of your code alive.

check for all system listeners, like phonelistener, global event listener, push etc and remove them in a shutdown method before calling system.exit.
also check the runtimestore, messagelistintegration etc
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
superdirt
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: Previous instance still active

Hi Simon,

I'm using many system listeners like PhoneListener, SystemListener, but I am not exiting the application before I see the error. I can't unregister the listeners while the application is running.

The error dialog shows when I try to return to the application after switching to another application or the home screen. If the dialog shows once, it shows again and again each time I try to enter the application until I reboot the phone.
Please use plain text.
Developer
simon_hain
Posts: 15,846
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Previous instance still active

thats strange.
do you have any special entry points?
if yes, which entry point is called by default? which one from the screen icon?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
superdirt
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: Previous instance still active

I only have one entry point and that is through public static void main.

Guesses are welcome :smileyhappy: I'm almost out of time on this one.

Thanks,
Scott
Please use plain text.
Developer
peter_strange
Posts: 19,598
Registered: ‎07-14-2008
My Device: Not Specified

Re: Previous instance still active

Like Simon, I am confused as to how you will see this if, when you press the icon, you are just bringing to foreground an already running application.

 

I would be looking at an alternate entry - even with an alternate entry there is still only one 'main'.  But you have different processing based on the args.  Is this the case with this app?

 

BTW, I believe I have seen cases where the message has been covered over by the actual application, so you see it on exit - but it has been there the whole time since you started the application. 

Please use plain text.
Developer
simon_hain
Posts: 15,846
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Previous instance still active

can you post the code of your main function?

Does this issue occur if you boot your device (after battery pull), launch the application, switch to another and switch back?
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
superdirt
Posts: 541
Registered: ‎05-17-2009
My Device: Not Specified

Re: Previous instance still active

Peter, I am seeing the dialog as you say - it gets pushed and then the application gets pushed on top of it and it's not seen until the application is minimized.

Simon, thinking about it now, I believe that even after rebooting and launching the application the error may persist.

public static void main(String[] args) {
      
        try {
        
        Object storeObject = RuntimeStore.getRuntimeStore().get(GUID);
        if (storeObject instanceof UiApplication) {
        ((UiApplication)storeObject).requestForeground();
        return;
        }
        
        } catch (Exception e) {
        // do nothing
        }
        
        MyApp app = new MyApp(args);
        
        app.enterEventDispatcher();
    }


I pass args to the app constructor but the args parameter is actually ignored. I recently added the RuntimeStore check to try and solve this issue but it's just a guess because I can't consistently reproduce the error.
Please use plain text.