Hi folks,
I'm currently trying to get a INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH action running for Spotify so that I can say 'play coldplay' via AutoVoice / AutoShare which would then open the spotify music app on my android device to play the song. Therefore I've created a new Action in AutoShare
{"name":"Spotify It","appname":"AutoShare","target":"Activity","action":"MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH","categories":[{"category":"android.intent.category.DEFAULT","name":"android.intent.category.DEFAULT"}],"hasOutput":false,"extras":[{"type":"String","name":"Query","description":"Terms to search for","key":"query"}]}
This works fine, however still requires me to pick the spotify app out of all apps which are able to handle this intent
Looking for sample code on how to properly call the Spotify Intent I found the following
snippet on stackoverflowIntent intent = new Intent(Intent.ACTION_MAIN);
intent.setAction(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
intent.setComponent(new ComponentName("com.spotify.mobile.android.ui", "com.spotify.mobile.android.ui.Launcher"));
intent.putExtra(SearchManager.QUERY, "michael jackson smooth criminal");
So what is required here is to add a Component to the Intent. I haven't seen any example till now how to use AutoShare Intents that set a Component.
Looking at the Autoshare Intent Builder I don't even think that's possible.
I tried something like that, but that didn't turn out to work.
{"name":"Spotify
It","appname":"AutoShare","target":"Activity","action":"MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH","categories":[{"category":"android.intent.category.DEFAULT","name":"android.intent.category.DEFAULT"}],"hasOutput":false,"package":"com.spotify.music","class":"com.spotify.music.MainActivity","extras":[{"type":"String","name":"Query","description":"Terms
to search for","key":"query"}]}
Thanks for your support,
kr Andrew