I have main an Activity
class, a broadcast class ( subclass of broadcast receiver ) and few other classes. I use a Handler
created in the broadcast class, for some things to do in future. But if some circumstances come ( user wants to exit app ), i want that Handler
to cancel (prevent from being executed ).
I read a lot of threads in SO on how to cancel Handlers
and I know how to from same class ( Handler.removeCallback (Runnable )
, Handler.removeMessages(0)
etc ). But I don't know how to cancel it from my Activity
. ( user presses exit button, and if handler is going to do some work i want to prevent that ).
So how do I reference that handler object (which is going to execute ) from the Activity
class ?