I am facing problem to work with VoiceInteractor. Here it my Manifest part:
<activity android:name=".ProductSearchActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="com.google.android.gms.actions.SEARCH_ACTION" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.VOICE" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEARCH" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<meta-data
android:name="android.app.searchable"
android:resource="@xml/searchable" />
</activity>
</application>
And in the Activity,
@Override
public void onResume() {
super.onResume();
if (isVoiceInteraction()) {
getVoiceInteractor().submitRequest(new VoiceInteractor.PickOptionRequest(prompt, optionArr, null) {
@Override
public void onPickOptionResult(boolean finished, Option[] selections, Bundle result) {
if (finished && selections.length == 1) {
showResult(selections[0].getIndex());
}
}
@Override
public void onCancel() {
getActivity().finish();
}
});
}
}
Whenever I am starting my app using "OK Google, search Jackets on MYCART", it starts the application, but isVoiceInteraction() is always returning false and getVoiceInteractor() is always returning null even if I am starting the app by google search. Can anyone help me on that?