Vardaan Sharma
Vardaan Sharma

Reputation: 1165

Running multiple instances of the same android service

If I create an android service using startService() followed by bindService(), and I never call stopService(). Now, every time my app calls startService() and bindService(), will it create a new instance of the service or reuse the existing one?

If a new instance is created...is the old instance still running or is it terminated?

Upvotes: 0

Views: 1856

Answers (2)

Paresh
Paresh

Reputation: 6857

will it create a new instance

No. If you're calling startService() even if service already running, it will call onStartCommand() with updated Intent

Ps, Service will run in only one process. So there is no such doubt to create another instance

Upvotes: 4

Alex Shutov
Alex Shutov

Reputation: 3282

It will not create another service, but redeliver your start Intent into onNewIntent() method

Upvotes: 0

Related Questions