dcow
dcow

Reputation: 7975

Why is using an implicit intent to start a service not safe?

When I start a service with an implicit intent I get a warning:

Implicit intents with startservice are not safe: ...

Why?

Edit:

I am using my own internal category that no other application should use and my service is not exported android:exported="false".

Upvotes: 3

Views: 12425

Answers (2)

Pankaj Kumar
Pankaj Kumar

Reputation: 82988

By Using Implicit Intents you have not specified a component, It means the component will be chosen by Android by given Intent-Action.

Using android:exported="false" will make sure that, other can not start your service. But what if I wrote an application with BroadcastReeciver which listens your Intent-Action and do some malicious work?

And same would happen when I declared a Service into my application and use the same category/ filter/ action.

So use Explicit Intents.

Upvotes: 11

handrenliang
handrenliang

Reputation: 1047

If you have multiple Service(s) with the same IntentFilter, System do not know which one should be started, and system will not ask users to choose.

Upvotes: 0

Related Questions