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".

有帮助吗?

解决方案

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.

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top