0

I am developing an application that implements a search provider. The behaviour that I am trying to accomplish is if an item is not found in the database, I want an item to show up in the search suggestions list that says something like

"select to add " + query + " to the database".

I have researched this endlessly, I have read all of the android search framework developer documentation, and I have searched on Google to no avail.

The only thing I could think of to accomplish this was in the database adapter, if no results are found create a MatrixCursor with the string I described above and the query however, this seems a little messy.

I would also somehow need to make it so that this item has a different Action Intent than a normal suggestion, as I need it to take the user to a page to add the item to the database.

This seems like a fairly reasonable thing to include in an application, I am not sure if I am missing something.

jamesmortensen
  • 33,636
  • 11
  • 99
  • 120
weaverx9x9
  • 495
  • 6
  • 17

1 Answers1

0

I figured this out. I used a MatrixCursor in my suggestions provider. I just checked if the results from the query were equal to null, if so, I returned the MatrixCursor. Now this seems very obvious. Also, in order to make this item do something different than results returned from the database I had add columns for

         SearchManager.SUGGEST_COLUMN_INTENT_ACTION
         SearchManager.SUGGEST_COLUMN_INTENT_DATA

to the matrix cursor. And then define the Uri and action intent for the result. Then, in my search activity just add an if for that particular action intent and then start the appropriate activity. Works great.

weaverx9x9
  • 495
  • 6
  • 17