Java.lang.IllegalArgumentException:Service Intent must be explicit
This means that the service must be explicitly called
This is how I used to bind the service.
He gave an error.
Because Google upgraded the SDK after 5.0
He requires that all service services must be explicitly called and not implicitly invoked
Workaround Use the following code
/*** * Android L (Lollipop, API) introduced a new problem when trying to invoke implicit intent, * "Java.lang. Illegalargumentexception:service Intent must is explicit "* * If you are using a implicit Intent, and know only 1 target would answer this intent, * This method would help you turn the implicit intent into the explicit form. * * Inspired from So answer:http://stackoverflow.com/a/26318757/1446466 * @paramContext *@paramimplicitintent-the Original Implicit intent *@returnExplicit Intent created from the implicit original Intent*/ Public StaticIntent createexplicitfromimplicitintent (context context, Intent implicitintent) {//Retrieve all services that can match the given intentPackagemanager pm =Context.getpackagemanager (); List<ResolveInfo> ResolveInfo = pm.queryintentservices (implicitintent, 0); //Make sure-one match was found if(ResolveInfo = =NULL|| Resolveinfo.size ()! = 1) { return NULL; } //Get Component Info and create ComponentNameResolveInfo serviceinfo = resolveinfo.get (0); String PackageName=ServiceInfo.serviceInfo.packageName; String ClassName=ServiceInfo.serviceInfo.name; ComponentName Component=Newcomponentname (PackageName, className); //Create a new intent. use the old one for extras and such reuseIntent explicitintent =NewIntent (implicitintent); //Set the component to be explicitexplicitintent.setcomponent (component); returnexplicitintent; }
Add a new code conversion function so that you can solve the problem
New Intent (); Intent.setaction ("Actionname.aidl.bank.BankService"); Intent intent1 new Intent (createexplicitfromimplicitintent (context,intent)); Bindservice (intent1,conn,bind_auto_create);
Java.lang.IllegalArgumentException:Service Intent must be explicit solution