Android SearchRecentSuggestionsProvider query limit

greenfrvr

I'm working with search suggestion framework and here is the case. I get some query string and make query from content resolver, but problem is that I can't limit the results. Found several solutions but they dont work for me.

My content provider is extending SearchRecentSuggestionsProvider and declared in manifest, here query uri Uri URI = Uri.parse("content://" + AUTHORITY + "/search_suggest_query");

sol 1: adding query parameter to uri

SearchSuggestionProvider.URI.buildUpon().appendQueryParameter(SearchManager.SUGGEST_PARAMETER_LIMIT, String.valueOf(5)).build()

sol 2: adding limit in sortOrder query parameter

getContentResolver().query(URI, null, "?", new String[]{searchQuery}, "_id asc limit 5");

In both cases query returns all rows from search suggestions. Does anyone know how to limit such a query?

RocketRandom

Below is the query method in the base class SearchRecentSuggestionsProvider in the framework

/**
     * This method is provided for use by the ContentResolver.  Do not override, or directly
     * call from your own code.
     */
    // TODO: Confirm no injection attacks here, or rewrite.
    @Override
    public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, 
            String sortOrder) {

Potentially you can override it and implement the limiting - but as you can see the comment above it clear states "do not override". In the existing method no limiting is enforced.

However I see in some of the other answers on stack-overflow and other sites that people do override it.

Example : Use SearchRecentSuggestionsProvider with some predefined terms?

Based on this I think you can try it out - override the query method and add your own implementation which supports limiting the results. Parse the SearchManager.SUGGEST_PARAMETER_LIMIT that you have used in the query method and use it to limit the results returned.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Over Query limit

分類Dev

LIMIT not working on complex query

分類Dev

Parse "or" query with limit returns all records ignoring limit on single query

分類Dev

Limit amount of parameters in query string

分類Dev

Cypher query limit results and delete

分類Dev

Ruby on Rails query limit in a range

分類Dev

Is there a limit to the query length being passed to ADODB?

分類Dev

Limit query by count distinct column values

分類Dev

Limit tables shown in DevExpress Dashboard - Query Builder

分類Dev

Is there a way to limit query results by values in an IN list?

分類Dev

Limit the initial (anchor) values of a recursive query (with statement)

分類Dev

Google Maps API OVER_QUERY_LIMIT

分類Dev

MongoDB : limit query to a field and array projection

分類Dev

SQL query - limit resulting query rows based on non sorted value

分類Dev

Android NotificationListenerService Background execution limit / Doze

分類Dev

How to limit broadcast to its own Android app

分類Dev

How to limit broadcast to its own Android app

分類Dev

Is there a limit on the number of rows I can update via an IN clause of a MySQL query?

分類Dev

How to apply a limit just for joining table in MySQL query?

分類Dev

Cake php query for limit that returns starting record no and total no records

分類Dev

Update php query limit whit js when load more

分類Dev

How to design the cassandra table for one query with a ordering and limit?

分類Dev

How can I limit the number of results of a specific part of an SQL query?

分類Dev

Android:SQLITE Select Query

分類Dev

Query.limitとQuery.skipの使い方は?

分類Dev

query_cache_sizeとquery_cache_limitの違いは何ですか?

分類Dev

php query "Order By .... Limit"を使用した後に "Order by"を使用する方法?

分類Dev

WebApi OData The limit of '0' for Top query has been exceeded, even after setting MaxTop

分類Dev

Google geocoding API: OVER_QUERY_LIMIT despite very low usage

Related 関連記事

  1. 1

    Over Query limit

  2. 2

    LIMIT not working on complex query

  3. 3

    Parse "or" query with limit returns all records ignoring limit on single query

  4. 4

    Limit amount of parameters in query string

  5. 5

    Cypher query limit results and delete

  6. 6

    Ruby on Rails query limit in a range

  7. 7

    Is there a limit to the query length being passed to ADODB?

  8. 8

    Limit query by count distinct column values

  9. 9

    Limit tables shown in DevExpress Dashboard - Query Builder

  10. 10

    Is there a way to limit query results by values in an IN list?

  11. 11

    Limit the initial (anchor) values of a recursive query (with statement)

  12. 12

    Google Maps API OVER_QUERY_LIMIT

  13. 13

    MongoDB : limit query to a field and array projection

  14. 14

    SQL query - limit resulting query rows based on non sorted value

  15. 15

    Android NotificationListenerService Background execution limit / Doze

  16. 16

    How to limit broadcast to its own Android app

  17. 17

    How to limit broadcast to its own Android app

  18. 18

    Is there a limit on the number of rows I can update via an IN clause of a MySQL query?

  19. 19

    How to apply a limit just for joining table in MySQL query?

  20. 20

    Cake php query for limit that returns starting record no and total no records

  21. 21

    Update php query limit whit js when load more

  22. 22

    How to design the cassandra table for one query with a ordering and limit?

  23. 23

    How can I limit the number of results of a specific part of an SQL query?

  24. 24

    Android:SQLITE Select Query

  25. 25

    Query.limitとQuery.skipの使い方は?

  26. 26

    query_cache_sizeとquery_cache_limitの違いは何ですか?

  27. 27

    php query "Order By .... Limit"を使用した後に "Order by"を使用する方法?

  28. 28

    WebApi OData The limit of '0' for Top query has been exceeded, even after setting MaxTop

  29. 29

    Google geocoding API: OVER_QUERY_LIMIT despite very low usage

ホットタグ

アーカイブ