Added in API level 31

SearchResults


open class SearchResults : Closeable
kotlin.Any
   ↳ android.app.appsearch.SearchResults

Encapsulates results of a search operation.

Each AppSearchSession#search operation returns a list of SearchResult objects, referred to as a "page", limited by the size configured by android.app.appsearch.SearchSpec.Builder#setResultCountPerPage.

To fetch a page of results, call getNextPage.

All instances of SearchResults must call android.app.appsearch.SearchResults#close() after the results are fetched.

This class is not thread safe.

Summary

Public methods
open Unit

open Unit

Retrieves the next page of SearchResult objects.

Public methods

close

Added in API level 31
open fun close(): Unit
Exceptions
java.lang.Exception if this resource cannot be closed
java.io.IOException if an I/O error occurs

getNextPage

Added in API level 31
open fun getNextPage(
    executor: Executor,
    callback: Consumer<AppSearchResult<MutableList<SearchResult!>!>!>
): Unit

Retrieves the next page of SearchResult objects.

The page size is configured by SearchSpec.Builder#setResultCountPerPage.

Continue calling this method to access results until it returns an empty list, signifying there are no more results.

Parameters
executor Executor: Executor on which to invoke the callback. This value cannot be null. Callback and listener events are dispatched through this Executor, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use Context.getMainExecutor(). Otherwise, provide an Executor that dispatches to an appropriate thread.
callback Consumer<AppSearchResult<MutableList<SearchResult!>!>!>: Callback to receive the pending result of performing this operation. This value cannot be null.