3

I am creating a music player application and I want to open my application using "OK Google" command. I searched a lot but I can't find anything related to that. I also defined the voice action in the intent filter like below but that didn't helped either.

<activity
        android:name="com.demo.musicplayer.ActivityMusicPlayer"
        android:configChanges="keyboardHidden|orientation"
        android:label="XPlayer">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <action android:name="android.intent.action.VOICE_COMMAND"/>
            <category android:name="android.intent.category.LAUNCHER" />

        </intent-filter>
    </activity>

It always opens the google play music application whenever I try with the voice command. Also I can't find any option to set my app as default. I am testing in Android Oreo

Vivek Mishra
  • 5,669
  • 9
  • 46
  • 84

1 Answers1

1

Well if you want an easier solution what you can do is say "ok google open 'myMusicApplication'" whatever the name of the application is

Then you can just say ok google unpause

I know it is kinda weird, but the phrase unpause is the only way to play music, because if you say play it'll suggest games for some reason.

ex:

Ok Google. Open Spotify.

Ok Google. Unpause.

this is the best way to go about this especially to be hands-free when driving and of course you can say

Ok Google. Skip

to move on to the next song

Hope this makes it much easier for you than actually developing an app for this.

This method even works for the app I'm currently building. I told Google to open my app and it worked. Of it isn't working for you I suggest maybe addidn Google authentication to your app. Maybe that will make the difference for Google to find an open your app.

Community
  • 1
  • 1