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
Highlighted
Developer
Posts: 144
Registered: ‎08-18-2012
My Device: Blackberry Curve 8520
My Carrier: Vodafone
Accepted Solution

Add SystemListener when any app comes to foreground?

Can we add SystemListener as soon as any app, in blackberry, comes to foregound? I mean, how can we check when ANY app comes to foreground and add SystemListener to it? 

Thanks in advance.

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Add SystemListener when any app comes to foreground?

Sorry, there is not a listener or notification when an app comes to the foreground nor is there any API to access a currently running Application and thus add a System Listener to it.

 

What are you trying to achieve?  Perhaps there are other alternatives. 

Developer
Posts: 144
Registered: ‎08-18-2012
My Device: Blackberry Curve 8520
My Carrier: Vodafone

Re: Add SystemListener when any app comes to foreground?

I have a requirement to do some startup work when ANY application starts, when Blackberry device is turned on..

I have the following code in my Application which implements SystemListener:

 

public void powerUp() {

System.out.println("BlackBerry is powering up");

StartUpWork();

 

}

 

I want to add  MySystemListener to every Application as soon as that app comes to foreground. Is this possible? 

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: Add SystemListener when any app comes to foreground?

You cannot add a listener to another application.

 

You might be able to look at "active" applications and figure out which one has the focus. You could also detect when one starts or stops using the ApplicationManager.getVisibleApplications

 

Developer
Posts: 144
Registered: ‎08-18-2012
My Device: Blackberry Curve 8520
My Carrier: Vodafone

Re: Add SystemListener when any app comes to foreground?

Ohk, Thanks RexDoug..