I am developing an app with a service. I try to import the app from Android 4.4 to Android 5 but I cannot bind to my service.
The service is registered in the AndroidManifest.
In my Application class,I start the service with :
startService(new Intent(this, MyService.class))
Now I am trying to connect to it in my Activity with :
bindService(new Intent(MyService.class.getName()), connection, Context.BIND_AUTO_CREATE)
but I always get an IllegalArgumentException in this line and I do not know what to do.
Here is my logact error-
PlayerActivity:java.lang.RuntimeException: Unable to resume activity {at.alex.player/at.alex.player.activities.PlayerActivity}: java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=at.alex.player.lib.soap.MyService }
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3521)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3552)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2872)
at android.app.ActivityThread.access$900(ActivityThread.java:181)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1476)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6134)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)
Caused by: java.lang.IllegalArgumentException: Service Intent must be explicit: Intent { act=at.alex.player.lib.soap.MyService }
at android.app.ContextImpl.validateServiceIntent(ContextImpl.java:2051)
at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:2159)
at android.app.ContextImpl.bindService(ContextImpl.java:2137)
at android.content.ContextWrapper.bindService(ContextWrapper.java:559)
at at.alex.player.activities.PlayerActivity.onResume(PlayerActivity.java:815)
at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1255)
at android.app.Activity.performResume(Activity.java:6495)
at android.app.ActivityThread.performResumeActivity(ActivityThread.java:3510)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:3552)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2872)
at android.app.ActivityThread.access$900(ActivityThread.java:181)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1476)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6134)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)