If you are using Internet Explorer, please remove blackberry.com from your compatibility view settings.

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
ankityadav4u
Posts: 231
Registered: ‎03-16-2011
My Device: 9700, 9550, and JDE
My Carrier: AIRTEL, BSNL

problem with timer on call back events

i want to maintain a timer to refresh, if screen is displayed it should run else it should not

currently i am using onObscured to cancel the timer and onExpose to scheduleTimer

but whenever onExpose is being called it gives illeagle state exception.

 

how can i solve this issue???


available on: Monday to Friday, Indian standard (day) time : )
  • Give kudos by clicking on the star icon to say "Thanks!" if you feel this response is helpful.
  • Click "Accept as Solution" if this post was what you needed. so that people who are trying to help will not waste their time reading a thread where no help is needed.

Please use plain text.
Developer
maadani
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: problem with timer on call back events

Are you re-initiating your timer on the OnExpose method?

 

According to Timer documentation, once you canceled a timer you can't reuse it.

 

Also, you can use the invokeLater method which seems to me more appropriate to this scenario.

 

E. 

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

Re: problem with timer on call back events

cancel the timertask instead of the timer.
onUiEngineAttached seems to be the most reliable method.
----------------------------------------------------------
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.