Code example for SearchManager

Methods: getSuggestions

1
 
    private long checkSourceInternal(String src, SearchableInfo searchable, String query) {
        Cursor cursor = null;
        try { 
            final long start = System.nanoTime();
            cursor = mSearchManager.getSuggestions(searchable, query);
            long end = System.nanoTime();
            long elapsed = end - start;
            if (cursor == null) {
                Log.d(TAG, src + ": null cursor in " + formatTime(elapsed)
                        + " for '" + query + "'");
            } else { 
                Log.d(TAG, src + ": " + cursor.getCount() + " rows in " + formatTime(elapsed)
                        + " for '" + query + "'");
            } 
            return elapsed;
        } finally { 
            if (cursor != null) {
                cursor.close();
            } 
        }