Don’t start a worker thread from a broadcast receiver
As soon as the
onReceive () method of the broadcast receiver returns , the broadcastreciever
object is marked for Garbage Collection . BroadCastReceiever Is really a
transient object so don’t try to run long running task in the onReceive ()
itself.
Good thing would be
to start a service rathan than starting a worker thread in broadcastreceiver
class.
Lets say if
Broadcastreceiver was the only application component in memory then as soon as
the onReceive () method returns , system thinks that its an empty process and
might just kill the application in the interest of freeing up memory cause these
are the ideal candidates to get killed first and system is unaware that you
have started a worker thread .
System will try to
keep that process around yey :-.after all isnt that what we want as an application developers
No comments:
Post a Comment