【发布时间】:2014-01-13 05:34:24
【问题描述】:
Google Play 音乐不再出现在 INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH 意图的“完成操作使用”列表中。我知道这曾经在 2.3 上有效,而 Pandora 和 Spotify 仍然出现。有没有人遇到过这个问题?
Intent intent = new Intent(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
intent.putExtra(SearchManager.QUERY, artistName);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
查看音乐 apk,我仍然可以通过意图过滤器中的正确操作发现活动仍然存在,但看起来他们缺少最初发布在 blog post announcing this feature 中的类别默认值
<activity android:name="com.google.android.music.VoiceActionsActivity" android:exported="true" android:process=":ui" android:launchMode="singleTask">
<intent-filter>
<action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />
</intent-filter>
</activity>
【问题讨论】:
-
查看 VoiceActionsActivity 的源代码,我得出结论,他们确实只忘记了这一行。媒体搜索似乎已实现。有谁知道启动 Google Play 音乐的另一种方法? Shazam 可以通过使用数据“play.google.com/store/music/…”启动 action.VIEW Intent 来做到这一点。所以他们以某种方式检索了内部的歌曲 ID。也许通过非官方的 GMusic-API 之一?
标签: android android-intent android-music-player