Intents to launch song, search for user in spotify app?

混江龙づ霸主 提交于 2019-11-30 14:14:09

问题


I'm trying to figure how apps like Shazam, for example, are able to launch spotify to play a specific song. Another question on SO suggested an intent like String spotifyUri = "spotify:user:username" and then parsing that as a Uri, but instead of searching for a user that just launches spotify. How can I make spotify play a track?

EDIT

Looking at Logcat, it looks like Shazam does this:

Starting: Intent { act=android.media.action.MEDIA_PLAY_FROM_SEARCH cmp=com.spotify.mobile.android.ui/.Launcher (has extras) } from pid 9959

How do I replicate this in my code?

EDIT

Ok, so apparently its something like this:

Intent 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"));

Now how do I tell it to search for a specific song?


回答1:


Ok, well apparently you need to use a stick a SearchManager.Query as an extra. This post sort of points to that.

So, it's intent.putExtra(SearchManager.QUERY, "michael jackson smooth criminal");



来源:https://stackoverflow.com/questions/7656720/intents-to-launch-song-search-for-user-in-spotify-app

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!