How to cancel TimerTask safely?
<p>I have been developing the Android application and I use <code>Timer</code> and <code>TimerTask</code> objects for executing one task after particular time. But there is one problem - sometimes I need to cancel timertask, but if I do it that Android will cause an <code>IllegalStateException</code>. How can I cancel the task safely? </p>
