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
New Developer
henbencau
Posts: 13
Registered: ‎08-26-2009
My Device: Not Specified

Blackground && Foreground in J2ME, which method will be invoked ?

Hello everybody,

I have an J2ME application for Blackberry which externs Midlet (not UIApplication of Blackberry)

When i press the Red bouton (the call bouton of Blackberry), the appli is in background mode. The pauseApp() de Midlet is invoked, so i can do something when the appli goes in background.

 

When i presse the menu bouton de blackberry (to able to choose which application i want to put in foreground), i chose my application. And then the application is in foreground. But i have some display problems (the display is blank)

 

My question is: Which method will be invoked when the appli goes back to foreground ? (so i can do something in this method to force the method repaint())

 

Thanks for your help. 

 

 

 

New Developer
zebulon
Posts: 6
Registered: ‎08-12-2009
My Device: Not Specified

Re: Blackground && Foreground in J2ME, which method will be invoked ?

when your app is set in foreground :

public void activate() //function in the main class
   

when your app is set in background :

public void deactivate() //function in the main class

New Developer
henbencau
Posts: 13
Registered: ‎08-26-2009
My Device: Not Specified

Re: Blackground && Foreground in J2ME, which method will be invoked ?

Thanks for your help 

But as i said: My application doesn't extern the UIApplication class of Blackberry . It externs the Midlet class. So i can't implement the active() and desactive() methods as you adviced me.

 

Otherwise, do you know how i can implement theses methods if my application doesn't extern UIApplication ?

 

Thanks 

 

 

New Developer
siva_guduru
Posts: 34
Registered: ‎01-13-2009
My Device: Not Specified

Re: Blackground && Foreground in J2ME, which method will be invoked ?

HI, If you are using MIDlet class along witha  Canvas then you can make use of showNotify() and hidNotify() of Canvas to take care of background and foreground process.

 

Thanks & REgards,

Siva Charan Guduru

New Developer
henbencau
Posts: 13
Registered: ‎08-26-2009
My Device: Not Specified

Re: Blackground && Foreground in J2ME, which method will be invoked ?

Thanks for your help.

You are right. As a standard J2ME application, it's true. showNotify() and hideNotify() will be invoked automatically.

 

But i tested on Blackberry Curve (8520) , when the application goes to background (by the red bouton of Blackberry), the pauseApp() is invoked (not hideNotify() method), but when the application goes back to foreground (by the menu bouton of Blackberry),  the showNotify() isn't invoked.

 

 

However, i found another solution to get around the display problem. 

 

Again one time, thanks for your help.

 

 

 

 

New Developer
siva_guduru
Posts: 34
Registered: ‎01-13-2009
My Device: Not Specified

Re: Blackground && Foreground in J2ME, which method will be invoked ?

That is very good that you did overcoem the problem, but it would be fine if you post how you have overcoemt he problem so that it will be useful for others as well.

 

Also are you using low level UI or high level UI in you app, cause if you are using high level UI then showNotify() and hideNotigy() will never be called.

 

Thanks & Regards,

Siva Charan Guduru