开发者

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

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 l开发者_高级运维ike 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?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜