In Android, if I send an intent from my app using implicit intent, and there are two services which have a matching intent filter, which service will get invoked ?
I know for activities, the user will be asked a choice through a pop up window. How does Android make the decision in case of services ?
Thanks.
Quoting myself:
In addition, what happens if there are two (or more) services installed on the device that claim to support the same
<intent-filter>
, but have different package names? You might think that this would fail on install, as happens with providers with duplicate authorities. Alas, it does not. Instead, once again, the first one in “wins”.So, if we have
BadService
andGoodService
, both responding to the same<intent-filter>
, and a client app tries to communicate toGoodService
via the explicit Intent matching that<intent-filter>
, it might actually be communicating withBadService
, simply becauseBadService
was installed first. The user is oblivious to this.
Moral of this story: don't use implicit Intents
with services.