Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Service Intent Needs to be Explicit Intent

When we start a service like following :

Intent in = new Intent();
in.setAction("com.android.myAction");
startService(in);

It gives an error : Service Intent must be explicit.

Why is this so. Why android requires service intent to be explicit?

like image 891
Tarun Deep Attri Avatar asked Sep 07 '15 11:09

Tarun Deep Attri


2 Answers

When you start a service with implicit intent unlike Activity, no user interface is involved. When multiple Services can handle an Intent, Android selects one at random; the user is not prompted to select a Service.

In case the malicious Service is bound to the calling application, then the attacker can return arbitrary malicious data or simply return a successful result without taking the requested action. The malicious Service can steal data and lie about completing requested actions.

like image 155
dn_c Avatar answered Oct 06 '22 06:10

dn_c


"To ensure your app is secure, always use an explicit intent when starting or binding your Service and do not declare intent filters for the service."(From Android developer) It must be because without it other apps will can start your service and etc.

like image 26
Vitalii Obideiko Avatar answered Oct 06 '22 08:10

Vitalii Obideiko