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
Regular Contributor
ramkumar
Posts: 50
Registered: ‎01-05-2011
My Device: 9300

Find active screen of application in Foreground

Hi,

     I want to get the active screen of application which is currently in Foreground.Is is possible?

New Developer
aartijain212006
Posts: 6
Registered: ‎08-13-2010
My Device: Not Specified

Re: Find active screen of application in Foreground

Hi,

 

I guess following code will work for you:

 

if  (Application.getApplication().isForeground()) {
  Screen scr = UiApplication.getUiApplication().getActiveScreen()​;
}

 

Thanks & Regards,

Aarti Jain

Regular Contributor
ramkumar
Posts: 50
Registered: ‎01-05-2011
My Device: 9300

Re: Find active screen of application in Foreground

Hi,

     Thanks for your reply.

 UiApplication.getUiApplication().getActiveScreen()​;  will return Active screen of my application.My requirement is my application always runs in background.I want to know active screen of any application which is currently running in foreground.

 

Thanks,

Ramkumar.

 

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Find active screen of application in Foreground

not possible
----------------------------------------------------------
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
Developer
peter_strange
Posts: 19,609
Registered: ‎07-14-2008
My Device: Not Specified

Re: Find active screen of application in Foreground

You can not, obtain access to any screens but your own.  So from your Background application, you will not be able to run code to find out what the current screen is. 

Regular Contributor
ramkumar
Posts: 50
Registered: ‎01-05-2011
My Device: 9300

Re: Find active screen of application in Foreground

Ok, We can't get the screen reference of Active screen of another application.Can i copy the selected text

on the current active screen of another application which is running in foreground from my application?

My actual requirement is  We have 200 mobile clients. I want to close unnecessary applications running in background to reduce the battery consumption from my program.I want to implement following steps in my application to close a application

 

(1)Bring the application to Foreground

(2)Press MENU key using Event Injection so all Menu items will be appear

(3)Scroll the Track ball to the CLOSE menu item  using Event Injection

(4)When Trackball reaches to CLOSE menu itme then I will click track wheel so that application will be closed.

 

All clients belong to our organization only.I want restrict user to open unnecessary applications in working hours so that battery consumption will be reduced.

 

So friends please tell me can i copy Menu item's selected text to clipboard? So that using that text i can know where the CLOSE menu item is plcace on MENU.After reaching CLOSE menu item  i will click Trackwheel so that Apllication will be closed.

 

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Find active screen of application in Foreground

using event injection for something this complicated is prone to fail, i would not suggest it. if you have 200 devices you might as well have a bes server. using it policies the devices can be administrated very tightly, for example disallowing the installation of 3rd party apps
----------------------------------------------------------
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
Regular Contributor
ramkumar
Posts: 50
Registered: ‎01-05-2011
My Device: 9300

Re: Find active screen of application in Foreground

We have no BES server to control mobile clients.It is very expensive.If we purchase BES server our project cost will be exceed.So please tell me any solution if you have.

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Find active screen of application in Foreground

bes express is free. if your company is too big for a bes express, no real way around it. the blackberry device security model is tightly bound to the BES, you don't have much control over other apps from your own application.
----------------------------------------------------------
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