5

I am developping an Android Music Player application. I'd like to integrate it with Google Assistant to control playback and search songs by voice. I already implemented a Media Session in my app according to instructions from the official documentation.

When requesting the Assistant to play something with my app, I have to say something like "Play some artist on MyApp". When I say "Play some artist", Assistant tells me that I don't have configured a default music provider.

This leads me to the following screen in the Google Assistant app:

enter image description here

I note that MyApp is not listed in "Your music services". My question is the following: what do I have to change in my app for it to be choosable as the default music service ?

For your information, here is the Manifest file:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="fr.nihilus.music">

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />

    <uses-feature
        android:name="android.hardware.audio.output"
        android:required="true" />

    <application
        android:name=".NihilusMusicApplication"
        android:allowBackup="true"
        android:fullBackupContent="@xml/backup"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        tools:ignore="GoogleAppIndexingWarning">

        <!-- Main activity for music browsing. -->
        <activity
            android:name=".HomeActivity"
            android:launchMode="singleTop"
            android:theme="@style/AppTheme.NoActionBar">

            <!-- Make this Activity visible in launcher -->
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>

            <!-- Make this activity available as the default music app. -->
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.APP_MUSIC" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

            <!-- Intent filter that enables voice searches, such as "Play the Beatles" -->
            <intent-filter>
                <action android:name="android.media.action.MEDIA_PLAY_FROM_SEARCH" />

                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

            <meta-data
                android:name="android.app.default_searchable"
                android:value=".ui.SearchResultActivity" />
            <meta-data
                android:name="android.app.shortcuts"
                android:resource="@xml/shortcuts" />
        </activity>

        <!-- Activity showing detail and tracks of an album. -->
        <activity
            android:name=".ui.albums.AlbumDetailActivity"
            android:parentActivityName=".HomeActivity"
            android:theme="@style/AppTheme.NoActionBar" />

        <!-- Activity for toggling user preferences. -->
        <activity
            android:name=".settings.SettingsActivity"
            android:label="@string/action_settings"
            android:parentActivityName=".HomeActivity" />

        <!--
            Activity to be opened as a dialog window when a track is selected
            from the file explorer.
         -->
        <activity android:name=".FileViewerActivity"
            android:theme="@style/AppTheme.FileViewer"
            android:excludeFromRecents="true">
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />

                <category android:name="android.intent.category.DEFAULT" />

                <data
                    android:mimeType="audio/*"
                    android:scheme="content" />
            </intent-filter>
        </activity>

        <!--
            Main music service, provides media browsing and media playback services to
            consumers through MediaBrowserService and MediaSession. Consumers connect to it through
            MediaBrowser (for browsing) and MediaController (for play session control)
        -->
        <service
            android:name=".service.MusicService"
            android:exported="true"
            android:label="@string/playback_service_label"
            android:process=":musicplayer"
            tools:ignore="ExportedService">
            <intent-filter>
                <action android:name="android.media.browse.MediaBrowserService" />
            </intent-filter>
        </service>

        <!--
            A receiver that will receive media buttons and send as intents to MusicService.
            Required on pre-Lollipop.
        -->
        <receiver android:name="android.support.v4.media.session.MediaButtonReceiver">
            <intent-filter>
                <action android:name="android.intent.action.MEDIA_BUTTON" />
            </intent-filter>
        </receiver>
    </application>

</manifest>
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Thibault Seisel
  • 1,197
  • 11
  • 23
  • 1
    Hey did you get any luck with this? I'm on the same path as you. – Fabio Oct 31 '19 at 01:02
  • @Fabio Since my app is only meant for playing local media I did not contact Google to include it as a music provider, therefore it is not listed. But you can still ask the Assistant to search content within your app with a query like the following : `play foo on myapp`. I noticed that you don't have to specify the app name if its MediaSession was the latest active session. Tell me if that works for you. – Thibault Seisel Oct 31 '19 at 09:20
  • not even with that phrase it is working. Where do you define "myapp", is it `android:label="myapp"` on the manifest? Also did you have to set up deep links? – Fabio Oct 31 '19 at 22:25
  • 1
    I also struggled to make the Assistant aware of my app. Its seems that the Assistant does not seem to recognize debug apks, you must have it published on Google Play (maybe having it signed is enough). The app name is defined as the `android:label` of the `` Manifest node. You must also have defined an exported `` the `android.media.browse.MediaBrowserService` intent-filter. – Thibault Seisel Nov 01 '19 at 13:13
  • 1
    do any of u have confirmation that the Assistant work only on published App? @Fabio, Thibault . i cant seem to make my App work with the Assistant with debug and signed apk. – Salah Hammouda Apr 08 '20 at 14:20

1 Answers1

2

Google assistant at the moment allows certain partner apps in the list. To partner I'm not sure exactly what you do. If you are at one of the large music provider companies you probably already have a Google Business Development rep who should be able to connect you with the right people.

If you aren't already in touch with Google somehow, there are various contact options on this page: https://developers.google.com/actions/ in the "Get the support you need from day one" section. I'd try on or more of these, which hopefully will get you to the right team.

Nick Fortescue
  • 13,530
  • 1
  • 31
  • 37