2

I would like to have two activities. FirstActivity should be started from launcher (by tapping on icon) and SecondActivity should be started by voice command (by saying "OK Google, start play example").

The problem is that for my current configuration only FirstActivity is started. Also method isVoiceInteraction returns false. I also don't see any values in flags that indicates that activity was started by voice.

Here's part of AndroidManifest.xml:

<application android:label="play example">
    <activity android:name="com.example.FirstActivity" android:label="play example">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <action android:name="com.example.EXAMPLE_ACTION" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>
    <activity android:name="com.example.SecondActivity" android:label="play example">
        <intent-filter>
            <action android:name="com.example.EXAMPLE_ACTION" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.VOICE" />
        </intent-filter>
    </activity>
</application>

Here it states:

To specify the text to say after "Start", specify a label attribute for the activtiy that you want to start.

But when I change label for SecondActivity it does not help.

I'm using API version 26.

How to setup configuration to handle described behavior?

hnefatl
  • 5,860
  • 2
  • 27
  • 49
Marcin Armatys
  • 599
  • 9
  • 25

1 Answers1

0

AFAIK isVoiceInteraction will always return false when the application is opened using "open" voice command. However, the scenario which you described, having another activity to respond to voice commands, should've worked.

The only thing that you might have missed is to put the action android.intent.action.MAIN in the second activity.