意图推出的歌曲,搜索用户在Spotify的应用程序? [英] Intents to launch song, search for user in spotify app?
问题描述
我试图找出如何应用程序,如快变,例如,能够推出Spotify的播放特定的歌曲。在SO另一个问题建议像意图字符串spotifyUri =Spotify的:用户:用户名
,然后解析,作为一个乌里
的,而是搜索,只是推出Spotify的用户。我怎样才能让Spotify的播放曲目?
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?
修改
看着logcat的,它看起来像Shazam的做到这一点:
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
我如何复制这在我的code?
How do I replicate this in my code?
修改
好了,所以显然它是这样的:
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?
推荐答案
好吧,好吧显然你需要用棍子一 SearchManager.Query
作为一个额外的费用。 这个帖子排序指向的。
Ok, well apparently you need to use a stick a SearchManager.Query
as an extra. This post sort of points to that.
所以,这是 intent.putExtra(SearchManager.QUERY,迈克尔·杰克逊顺利刑事);
这篇关于意图推出的歌曲,搜索用户在Spotify的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!