I am trying to get the search result from Google Now. I have followed the instructions on http://android-developers.blogspot.com/2014/10/the-fastest-route-between-voice-search.html and https://developer.android.com/guide/components/intents-common.html#SearchOnApp.
It works through ADB but not after I publish the app to the PlayStore. When trying the search ("Search for something on Casa Controller) it says that that it is opening the app but then doesn't. Any ideas?
ADB Command Tested
adb shell am start -a com.google.android.gms.actions.SEARCH_ACTION --es query "salad" io.biddleinc.casacontroller
My Android Manifest
<?xml version='1.0' encoding='utf-8'?>
<manifest android:hardwareAccelerated="true" android:versionCode="20702" android:versionName="2.7.2" android:windowSoftInputMode="adjustPan" package="io.biddleinc.casacontroller" xmlns:android="http://schemas.android.com/apk/res/android">
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.VIBRATE" />
<application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:exported="true" android:label="@string/app_name" android:launchMode="singleTop" android:name="HelloCordova" android:theme="@android:style/Theme.Black.NoTitleBar">
<intent-filter>
<action android:name="com.google.android.gms.actions.SEARCH_ACTION" />
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="android.app.default_searchable" android:value=".SearchActivity" />
</activity>
<activity android:label="@string/app_name" android:name=".SearchActivity">
<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>
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="22" />
</manifest>
My searchable.xml
<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
android:label="@string/app_label"
android:hint="@string/search_hint">
</searchable>
My strings.xml
<?xml version='1.0' encoding='utf-8'?>
<resources>
<string name="app_name">Casa Controller</string>
<string name="app_label">Casa Controller</string>
<string name="search_hint">What do you want to happen</string>
</resources>
My Activity.java
package io.biddleinc.casacontroller;
import android.app.SearchManager;
import android.content.Intent;
import android.os.Bundle;
import org.apache.cordova.*;
public class HelloCordova extends CordovaActivity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.init();
Intent intent = getIntent();
String url = "file:///android_asset/www/login_full.html";
if (Intent.ACTION_SEARCH.equals(intent.getAction())
|| "com.google.android.gms.actions.SEARCH_ACTION".equals(intent.getAction())) {
url += "?search=" + intent.getStringExtra(SearchManager.QUERY);
}
super.loadUrl(url);
// Set by <content src="index.html" /> in config.xml
//super.loadUrl(Config.getStartUrl());
//super.loadUrl("file:///android_asset/www/index.html");
}
@Override
protected void onNewIntent(Intent intent)
{
//super.onNewIntent(intent);
if (Intent.ACTION_SEARCH.equals(intent.getAction())
|| "com.google.android.gms.actions.SEARCH_ACTION".equals(intent.getAction())) {
String phrase = intent.getStringExtra(SearchManager.QUERY);
String url = "javascript: { recongizeSpeechFromGoogle('"+ phrase + "'); }";
super.loadUrl(url);
}
//Forward to plugins
if (this.appView != null)
this.appView.onNewIntent(intent);
}
}