Amin Pinjari
Amin Pinjari

Reputation: 2173

Avoid Multiple Instances for a Service

I have created a foreground service, which is working perfectly and performs tasks in the background, But whenever I call startForegroundService onCreate method is getting called.

As I know and according to documentation, Service is a kind of singleton class but still, multiple instances are getting created.

Does anyone have any idea How can I avoid multiple instances of service??

Upvotes: 1

Views: 399

Answers (1)

Amin Pinjari
Amin Pinjari

Reputation: 2173

Service was getting destroyed but the handler whose instance was getting created repeatedly here. Issue solved by removing handler in onDestroy of Service @greeble31 Thanks for your hint

Upvotes: 1

Related Questions