Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/224.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Google Play Music不再支持媒体搜索播放_Android_Android Intent_Android Music Player - Fatal编程技术网

Android Google Play Music不再支持媒体搜索播放

Android Google Play Music不再支持媒体搜索播放,android,android-intent,android-music-player,Android,Android Intent,Android Music Player,Google Play Music不再出现在INTENT\u action\u MEDIA\u Play\u FROM\u SEARCHINTENT的“Complete action using”列表中。我知道它曾经在2.3上运行,潘多拉和Spotify仍然会出现。以前有人遇到过这个问题吗 Intent intent = new Intent(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH); intent.putExtra(SearchMana

Google Play Music不再出现在
INTENT\u action\u MEDIA\u Play\u FROM\u SEARCH
INTENT的“Complete action using”列表中。我知道它曾经在2.3上运行,潘多拉和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,我仍然可以确定活动仍然存在,并且在意图过滤器中有正确的操作,但是看起来它们缺少了最初发布在


我找到了一个解决方法:可以手动将意图的类名设置为VoiceActionsActivity,如下所示:

Intent intent = new Intent();
intent.setClassName("com.google.android.music","com.google.android.music.VoiceActionsActivity");
intent.setAction(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
intent.putExtra(SearchManager.QUERY, "chromeo - fancy footwork");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
谷歌音乐显然仍然不会出现在选择器对话框中,但是你可以添加一个自定义按钮来打开谷歌音乐


编辑:这实际上是可行的,请看这个问题:然而,这将从应用程序中删除“设置默认值”按钮,所以它不是很完美。另一种选择是使用
getPackageManager().queryIntentActivities()

构建您自己的选择器查看VoiceActionsActivity的源代码,我得出结论,他们确实只忘记了这一行。媒体搜索似乎已经实现。有人知道谷歌音乐播放的另一种方式吗?Shazam可以通过使用数据“”启动action.VIEW Intent来实现这一点。因此,他们不知何故检索到了内部歌曲ID。也许通过一个非官方的音乐API?
Intent intent = new Intent();
intent.setClassName("com.google.android.music","com.google.android.music.VoiceActionsActivity");
intent.setAction(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
intent.putExtra(SearchManager.QUERY, "chromeo - fancy footwork");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);