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
misty83
Posts: 745
Registered: ‎01-04-2009
My Device: 8300, 8800, 8700f, 9000
Accepted Solution

can midlet on bb be a background app?

hi,
i must write a midlet on bb - is it possible to make it background application? (i know that using 'extends Application' in bb it can be easily done, but i must have midlet).

regards
Developer
BBDeveloper
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: can midlet on bb be a background app?

You could try something like.. after launching the midlet application set the display to null.

Use Search. "Accept Solution" If the problem is resolved.
Developer
misty83
Posts: 745
Registered: ‎01-04-2009
My Device: 8300, 8800, 8700f, 9000

Re: can midlet on bb be a background app?

You know, actually it seems that it works. i was worried if the midlet is running or paused, so i wrote a small test class:

 

public class Test extends MIDlet{ private Timer _timer; private UiEngine _ui; private Screen _screen; public Test(){ } public void startApp(){ Display.getDisplay(this).setCurrent(null); _timer = new Timer(); synchronized(_timer){ _timer.scheduleAtFixedRate(new TimerTask(){ int _counter; public void run(){ _counter++; if(_counter == 10){ notifyUser("it works!"); _timer.cancel(); notifyUser("timer stop"); // System.exit(0); } } }, 0, 2000); } } public void pauseApp(){} public void destroyApp(boolean _ignore){} public void notifyUser(String data) { _ui = Ui.getUiEngine(); _screen = new Dialog(Dialog.OK, data, Dialog.OK, Bitmap.getPredefinedBitmap(Bitmap.EXCLAMATION), Manager.VERTICAL_SCROLL); _ui.queueStatus(_screen, 1, true); }//end of notifyUser method }

 

 

 

and ok-after 20 secs i got alerts 'it works!' and then 'timer stop'. also-i do not have any screen in this midlet, i've got only an icon. so it is what i wanted. i still have one question. cause after

if(_counter == 10){

   _timer.cancel(); 

}

 

i want to close app. i've tried System.exit(0) but then i got an error: 'Uncaught exception: Security exception'. do not know why.. do You maybe know how can i close the app?

Developer
BBDeveloper
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: can midlet on bb be a background app?

try calling destroyApp(true) and notifyDestroyed().

Use Search. "Accept Solution" If the problem is resolved.
Developer
misty83
Posts: 745
Registered: ‎01-04-2009
My Device: 8300, 8800, 8700f, 9000

Re: can midlet on bb be a background app?

great, thx!

 

 

 ps.

 do You maybe know why System.exit(0) occurs such an error?

 

  regards

Developer
BBDeveloper
Posts: 3,951
Registered: ‎07-15-2008
My Device: Not Specified

Re: can midlet on bb be a background app?

Well I guess you need to debug it.

 

 


Use Search. "Accept Solution" If the problem is resolved.