I am trying to implement my first SearchView
with suggestions. As far as I understand, I have two possibilities to provide suggestions:
- In the
searchable.xml
configure a custom content provider usingandroid:searchSuggestAuthority
which is then queried for suggestions (system callsquery()
method on the specified custom content provider) - Or implement
SearchView.OnQueryTextListener
and provide the suggestions viaSearchView.setSuggestionsAdapter
Did I understand that correctly? Am I correct that the second possiblity gives me the possiblity to handle the search logic inside a Fragment
/ViewModel
without creating a content provider as required for the first possiblity?
Is there any advantage of one method over the other? Which one should I use? The Adding custom suggestions guide
only mentions the first possiblity (using a custom ContentProvider), but that guide seems to be already quite old.