I understand the principles of implicit/explicit intents but I am unable to create an explicit intent from the following code:
getActivity().startService(new Intent(PowerampAPI.ACTION_API_COMMAND)
.putExtra(PowerampAPI.COMMAND, PowerampAPI.Commands.OPEN_TO_PLAY)
.setData(PowerampAPI.ROOT_URI.buildUpon()
.appendEncodedPath("folder_playlist_entries")
.appendEncodedPath(playlist_id)
.appendEncodedPath("files")
.build()));
Running this code gives the following error:
.IllegalArgumentException: Service Intent must be explicit: Intent { act=com.maxmpz.audioplayer.API_COMMAND dat=content://com.maxmpz.audioplayer.data/folder_playlist_entries/5/files (has extras) }
Question: How to turn this into an explicit intent ?
try this, it may help.
I understand that you are trying to start a service. If that is the case, you will have to provide two arguments for new Intent(), like this:
Such a decleration provides a explicit intent to the startService method.
You can furthur refer ato this link about service and how to start a service:
https://developer.android.com/reference/android/content/Context.html#startService(android.content.Intent)
I found a piece of code which turns the implicit intent into an explicit one. Source: http://blog.android-develop.com/2014/10/android-l-api-21-javalangillegalargumen.html
and