谷歌助手没有捕获查询方法

时间:2018-07-20 03:29:23

标签: java android-tv google-assistant-sdk

我创建了从ContentProvider继承的SongContentProvider

public Cursor query(
    @NonNull Uri uri,
    @Nullable String[] projection,
    @Nullable String selection,
    @Nullable String[] selectionArgs,
    @Nullable String sortOrder) {

    Log.d(TAG, uri.toString());

    if (mUriMatcher.match(uri) == SEARCH_SUGGEST) {
        Log.d(TAG, "Search suggestions requested.");

        String query = uri.getLastPathSegment();
        try {
            query = java.net.URLDecoder.decode(query, "UTF-8");
        } catch (UnsupportedEncodingException e) {
            //e.printStackTrace();
        }
        if (query!=null && query.length() > 0 && !query.equalsIgnoreCase("dummy")) {
            Log.d(TAG, "query: " + query);              
            return search(query);
        }
    } else {
        Log.d(TAG, "Unknown uri to query: " + uri);
        throw new IllegalArgumentException("Unknown Uri: " + uri);
    }

    return  null;
}

当我按Mibox 4K遥控器上的麦克风按钮时,查询获取的值是“虚拟”, 但动作完成后,不会调用查询方法。我的Mibox运行Android 8.0 我在Sony TV(android 7)上工作

我从Web api URL http:/abc.com/api/info?slot = x获得了商品信息 searchable.xml文件

<searchable xmlns:android="http://schemas.android.com/apk/res/android"
  android:hint="@string/search_hint"
  android:includeInGlobalSearch="true"
  android:label="@string/search_label"
  android:icon="@drawable/lb_ic_in_app_search"
  android:searchSettingsDescription="@string/settings_description"
  android:searchSuggestAuthority="com.c.appid"
  android:searchSuggestIntentAction="android.intent.action.VIEW"
  android:searchSuggestIntentData="content://com.c.appid/song"
  android:queryAfterZeroResults="true"
  android:searchSuggestPath="search"
  android:searchSuggestThreshold="0" />

0 个答案:

没有答案