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
arkadyz
Posts: 2,268
Registered: ‎07-08-2009
My Device: various

Of Timers, Timer Tasks and battery drain

Hello, all,

Recently, I've found that my application causes a lot of battery drain even when running in the background.  The reason was one TimerTask running at 20 Hz.  I started cancelling it when it was not needed and the problem went away.

 

However,I guess I went overboard while doing it as I'm cancelling the Timer as well, restarting both (Timer and TimerTask) when necessary.  Would just cancelling the TimerTask solve the problem?  In other words, is an active Timer without scheduled tasks a battery drain?  Or is it just a Thread that is permanently blocked?  I can find out myself, but if anyone has done such experiments, please let me know.

 

If there is no response here, I'll respond to this post with my own findings in a few days.

 

Regards,

     Arkady.

----------------------------------------------------------
please click 'Accept Solution' on posts that provide the solution to the question you've posted. Don't say "Thanks", press 'Like' button instead!
Please use plain text.
Developer
simon_hain
Posts: 16,209
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Of Timers, Timer Tasks and battery drain

a timer without any timertasks should not drain the battery. if you schedule a timertask the timer is notified and wakes up i assume.
----------------------------------------------------------
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.
Developer
ankit2grover
Posts: 159
Registered: ‎08-19-2008
My Device: Not Specified

Re: Of Timers, Timer Tasks and battery drain

Can u please elaborate what kind of task your application is doing in the background..........?...........It may be ur application doing some gps , internet connection tasks after scheduled intervals .............Timer task generally (if your application not using gps,internet ) doesn't drain battery.... it just invokes specified task after some regular intervals..................But am not Knighted on this, this info is am giving only with my best of knowledge 

Please use plain text.