2

I am using a ContentProvider to provide search suggestions for a Searchable Configuration in my app.

I successfully receive query calls and when I create a MatrixCursor, add several rows, and return the cursor, they are properly displayed in the search results.

However, if I make an asynchronous network request to fetch results, then populate the same MatrixCursor with additional rows, these items are not populated in the search results.

I have tried calling

synchronized (cursor) {
    cursor.notifyAll();
}

after adding the additional rows, but this does not appear to produce the desired result.

What is the best practice for asynchronously providing search results by way of a network request?

dcarr622
  • 1,576
  • 4
  • 15
  • 23
  • you could try cursor.requery() but... it is deprecated in API level 11, are you using a SearchView ? – pskink Jun 16 '15 at 05:06
  • 1
    This is actually for search suggestions on Android TV - https://developer.android.com/training/tv/discovery/searchable.html – dcarr622 Jun 16 '15 at 05:18
  • 1
    Also, I think the search interface itself is what would need to requery the cursor - I'm supplying the cursor from my `ContentProvider` but I can't control what happens to it after that. – dcarr622 Jun 16 '15 at 05:19
  • is your search invoked by a system or in your app private SearchView? – pskink Jun 16 '15 at 05:25
  • 1
    It's invoked by the System - Android TV has a centralized search view that pulls results from all apps that provide a searchable configuration + ContentProvider in the manifest. – dcarr622 Jun 16 '15 at 06:01
  • so if you cannot use your app private SearchView (which would simplify things a lot) i think that Cursor#requery() is the thing you could try... – pskink Jun 16 '15 at 06:06
  • @dcarr622 I have got the same problem. I can't fill asynchronously the cursor which is returned by ContentProvider.query(). Did you solve this problem? That's very important for me. – jan_kowalski_314 Aug 16 '15 at 16:17

0 Answers0