3

Google Play Music no longer appears in the "Complete action using" list for the INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH intent. I know this used to work on 2.3 and Pandora and Spotify still show up. Has anyone faced this issue before?

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

Peeking into the music apk, I can still that the activity is still there with the correct action in the intent-filter, but it looks like they're missing the Category Default that was original posted in the 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>
Zong
  • 6,160
  • 5
  • 32
  • 46
smith324
  • 13,020
  • 9
  • 37
  • 58
  • Looking at the source code of VoiceActionsActivity leads me to the conclusion, that they did indeed only forget this one line. Media searching seems to be implemented. Does anyone know another method of launching Google Play Music? Shazam is able to do it, by launching an action.VIEW Intent with data "https://play.google.com/store/music/album?id=Bf34irxf4drzf3c5lyvayxjovea&tid=song-T2bqvoiapytry5giuebuc5z6s4y&PaffiliateId=6332674904". So they somehow retrieved the internal Song-Ids. Maybe through one of the unoffical GMusic-APIs? – Nils Borrmann Feb 13 '14 at 18:30

1 Answers1

3

I found a workaround to this: One can manually set the ClassName for the Intent to the VoiceActionsActivity, like this:

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

Google Music obviously still won't show up in the chooser dialog, but you could for example add a custom button that will open Google Music.

EDIT: This is actually doable, see this question: add or remove options from createChooser However, this will remove the "Set Default" Button from the app, so it's not quite perfect. Another option would be building your own Chooser using getPackageManager().queryIntentActivities().

Community
  • 1
  • 1
Nils Borrmann
  • 245
  • 2
  • 7