Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6894437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:46:58+00:00 2026-05-27T06:46:58+00:00

I’m trying to make custom suggestion to search dialog. I’m using a urimatcher to

  • 0

I’m trying to make custom suggestion to search dialog. I’m using a urimatcher to match uri. But it dont work. I always get the exception ” java.lang.IllegalArgumentException: Unknown Uri: content://com.simple.search.SuggestionProvider/search_suggest_query/?limit=50″. Please explain this to me. What can I do to resolve this?

private static final UriMatcher sURIMatcher = makeUriMatcher();
public Cursor query(Uri uri, String[] projection, String selection,
        String[] selectionArgs, String sortOrder) {
    // Use UriMatcher, to find out what type of request received. Next, form
    // the corresponding query to the database
    switch (sURIMatcher.match(uri)) {
    case SEARCH_SUGGEST:
        if (selectionArgs == null) {
            throw new IllegalArgumentException(
                    "selectionArgs must be provided for the Uri: " + uri);
        }
        return getSuggestions(selectionArgs[0]);
    case SEARCH_TESTS:
        if (selectionArgs == null) {
            throw new IllegalArgumentException(
                    "selectionArgs must be provided for the Uri: " + uri);
        }
        return search(selectionArgs[0]);
    case GET_TEST:
        return getRecord(uri);
    default:
        throw new IllegalArgumentException("Unknown Uri: " + uri);
    }

makeUrimatcher

private static UriMatcher makeUriMatcher() {

    UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
    // For the record
    matcher.addURI(AUTHORITY, "tests", SEARCH_TESTS);
    matcher.addURI(AUTHORITY, "tests/#", GET_TEST);
    // For suggestions table
    matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY,
            SEARCH_SUGGEST);
    matcher.addURI(AUTHORITY, SearchManager.SUGGEST_URI_PATH_QUERY + "/*",
            SEARCH_SUGGEST);
    return matcher;
}

logcat

11-30 14:16:27.295: I/ActivityThread(1638): Publishing provider com.simple.search.SuggestionProvider: com.simple.search.SuggestionProvider
11-30 14:16:35.424: D/com.simple.search.com.simple.search.SuggestionProvider(1638): Unknown Uri: content://com.simple.search.SuggestionProvider/search_suggest_query/?limit=50
11-30 14:16:35.424: E/DatabaseUtils(1638): Writing exception to parcel
11-30 14:16:35.424: E/DatabaseUtils(1638): java.lang.IllegalArgumentException: Unknown Uri: content://com.simple.search.SuggestionProvider/search_suggest_query/?limit=50
11-30 14:16:35.424: E/DatabaseUtils(1638):  at com.simple.search.SuggestionProvider.query(SuggestionProvider.java:122)
11-30 14:16:35.424: E/DatabaseUtils(1638):  at android.content.ContentProvider$Transport.bulkQuery(ContentProvider.java:117)
11-30 14:16:35.424: E/DatabaseUtils(1638):  at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:98)
11-30 14:16:35.424: E/DatabaseUtils(1638):  at android.os.Binder.execTransact(Binder.java:287)
11-30 14:16:35.424: E/DatabaseUtils(1638):  at dalvik.system.NativeStart.run(Native Method)

searchable.xml

<?xml version="1.0" encoding="utf-8"?>
<searchable xmlns:android="http://schemas.android.com/apk/res/android"
    android:hint="@string/search_hint" 
    android:label="@string/app_label"
    android:searchSuggestAuthority="com.simple.search.SuggestionProvider"
    android:searchSuggestIntentAction="android.intent.action.VIEW"
    android:searchSuggestIntentData="content://com.simple.search.SuggestionProvider/tests"
    />

Manifest

....
....
        <activity
            android:label="@string/app_name"
            android:name=".SimpleSearch" >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.SEARCH" />
            </intent-filter>
                <meta-data android:name="android.app.searchable"
                   android:resource="@xml/searchable"/>
        </activity>
....
....
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T06:46:58+00:00Added an answer on May 27, 2026 at 6:46 am

    To avoid discussion i’ll change this answer if you provide more information…

    but for now …

    you have android:searchSuggestIntentData="content://com.simple.search.SuggestionProvider/tests" in xml

    so you have to change

    private static UriMatcher makeUriMatcher() {
    
        UriMatcher matcher = new UriMatcher(UriMatcher.NO_MATCH);
        // For the record
        matcher.addURI(AUTHORITY, "tests", SEARCH_TESTS);
        matcher.addURI(AUTHORITY, "tests/#", GET_TEST);
        // For suggestions table
        matcher.addURI(AUTHORITY, "tests/" + SearchManager.SUGGEST_URI_PATH_QUERY,
                SEARCH_SUGGEST);
        matcher.addURI(AUTHORITY, "tests/" + SearchManager.SUGGEST_URI_PATH_QUERY + "/*",
                SEARCH_SUGGEST);
        return matcher;
    }
    

    if you dont see differences i added “tests/”

    so now it will match content://com.simple.search.SuggestionProvider/tests/search_suggest_query?limit=50 which is exactly what QSB will send …

    anyway you can/should add limit to your query

    case SEARCH_SUGGEST:
        if (selectionArgs == null) {
            throw new IllegalArgumentException(
                    "selectionArgs must be provided for the Uri: " + uri);
        }
        final String limit = uri.getQueryParameter(SearchManager.SUGGEST_PARAMETER_LIMIT);
        return getSuggestions(selectionArgs[0], limit);
    

    and then in getSuggestions

    helper.getReadableDatabase().query(table, projection,
                        selection, selectionArgs, null, null, sortOrder, limit);
    

    EDIT:

    AUTHORITY + "tests/" + SearchManager.SUGGEST_URI_PATH_QUERY should be the same as android:searchSuggestIntentData !!!

    EDIT2: from doc http://developer.android.com/guide/topics/search/adding-custom-suggestions.html

    selection The value provided in the android:searchSuggestSelection
    attribute of your searchable configuration file, or null if you have
    not declared the android:searchSuggestSelection attribute. More about
    using this to get the query below. selectionArgs Contains the search
    query as the first (and only) element of the array if you have
    declared the android:searchSuggestSelection attribute in your
    searchable configuration. If you have not declared
    android:searchSuggestSelection, then this parameter is null. More
    about using this to get the query below.

    add android:searchSuggestSelection=" ? "

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.