I’m starting a BroadCast Receiver when net Connectivity Changes in Android. The BroadCast Receiver Starts a Service which handles a Async task to fetch data from server. The problem is little weird, when i test in my device the Service OnCreate method is run for first time “Hurray!” but when i disconnect the network and again try to connect. The BroadCast is Read but not the Service. Am I missing something here? or Is this a bug? or should there be any Intent Actions when I start my Service? Please Help me.
I’m starting a BroadCast Receiver when net Connectivity Changes in Android. The BroadCast Receiver
Share
The onCreate method in service runs only once till the entire life of service. However, calls to onStartCommand method can be made multiple times by calling startService. If your service is destroyed and then run again, the onCreate will be called again.
This is what this document tells:
onCreate()The system calls this method when the service is first created, to perform one-time setup procedures (before it calls either onStartCommand() or onBind()). If the service is already running, this method is not called.