Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels) Summary: [Methods](https://developer.android.com/reference/android/app/appsearch/SearchResults#pubmethods) \| [Inherited Methods](https://developer.android.com/reference/android/app/appsearch/SearchResults#inhmethods)

# SearchResults

*** ** * ** ***

` public class SearchResults `   
` extends https://developer.android.com/reference/java/lang/Object ` ` implements https://developer.android.com/reference/java/io/Closeable `

|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.app.appsearch.SearchResults |

<br />

*** ** * ** ***

Encapsulates results of a search operation.

Each `https://developer.android.com/reference/android/app/appsearch/AppSearchSession#search(java.lang.String,%20android.app.appsearch.SearchSpec)` operation returns a list of `https://developer.android.com/reference/android/app/appsearch/SearchResult` objects, referred to as a "page", limited by the size configured by `https://developer.android.com/reference/android/app/appsearch/SearchSpec.Builder#setResultCountPerPage(int)`.

To fetch a page of results, call `https://developer.android.com/reference/android/app/appsearch/SearchResults#getNextPage(java.util.concurrent.Executor,%20java.util.function.Consumer<android.app.appsearch.AppSearchResult<java.util.List<android.app.appsearch.SearchResult>>>)`.

All instances of `https://developer.android.com/reference/android/app/appsearch/SearchResults` must call `https://developer.android.com/reference/android/app/appsearch/SearchResults#close()` after the results are fetched.

This class is not thread safe.

## Summary

| ### Public methods ||
|---|---|
| ` void` | ` https://developer.android.com/reference/android/app/appsearch/SearchResults#close()() ` Closes this stream and releases any system resources associated with it. |
| ` void` | ` https://developer.android.com/reference/android/app/appsearch/SearchResults#getNextPage(java.util.concurrent.Executor,%20java.util.function.Consumer<android.app.appsearch.AppSearchResult<java.util.List<android.app.appsearch.SearchResult>>>)(https://developer.android.com/reference/java/util/concurrent/Executor executor, https://developer.android.com/reference/java/util/function/Consumer<https://developer.android.com/reference/android/app/appsearch/AppSearchResult<https://developer.android.com/reference/java/util/List<https://developer.android.com/reference/android/app/appsearch/SearchResult>>> callback) ` Retrieves the next page of `https://developer.android.com/reference/android/app/appsearch/SearchResult` objects. |

### Inherited methods

From class ` https://developer.android.com/reference/java/lang/Object ` ` https://developer.android.com/reference/java/lang/Object` ` https://developer.android.com/reference/java/lang/Object#clone()() `

Creates and returns a copy of this object.
` boolean` ` https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object)(https://developer.android.com/reference/java/lang/Object obj) `

Indicates whether some other object is "equal to" this one.
` void` ` https://developer.android.com/reference/java/lang/Object#finalize()() `

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
` final https://developer.android.com/reference/java/lang/Class<?>` ` https://developer.android.com/reference/java/lang/Object#getClass()() `

Returns the runtime class of this `Object`.
` int` ` https://developer.android.com/reference/java/lang/Object#hashCode()() `

Returns a hash code value for the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#notify()() `

Wakes up a single thread that is waiting on this object's monitor.
` final void` ` https://developer.android.com/reference/java/lang/Object#notifyAll()() `

Wakes up all threads that are waiting on this object's monitor.
` https://developer.android.com/reference/java/lang/String` ` https://developer.android.com/reference/java/lang/Object#toString()() `

Returns a string representation of the object.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long,%20int)(long timeoutMillis, int nanos) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait(long)(long timeoutMillis) `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*, or until a certain amount of real time has elapsed.
` final void` ` https://developer.android.com/reference/java/lang/Object#wait()() `

Causes the current thread to wait until it is awakened, typically by being *notified* or *interrupted*.
From interface ` https://developer.android.com/reference/java/io/Closeable ` ` abstract void` ` https://developer.android.com/reference/java/io/Closeable#close()() `

Closes this stream and releases any system resources associated with it.
From interface ` https://developer.android.com/reference/java/lang/AutoCloseable ` ` abstract void` ` https://developer.android.com/reference/java/lang/AutoCloseable#close()() `

Closes this resource, relinquishing any underlying resources.

## Public methods

### close

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void close ()
```

Closes this stream and releases any system resources associated with it. If the stream is already closed then invoking this method has no effect.

As noted in `https://developer.android.com/reference/java/lang/AutoCloseable#close()`, cases where the close may fail require careful attention. It is strongly advised to relinquish the underlying resources and to internally *mark* the `Closeable` as closed, prior to throwing the `IOException`.

<br />

### getNextPage

Added in [API level 31](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)

```
public void getNextPage (Executor executor, 
                Consumer<AppSearchResult<List<SearchResult>>> callback)
```

Retrieves the next page of `https://developer.android.com/reference/android/app/appsearch/SearchResult` objects.

The page size is configured by `https://developer.android.com/reference/android/app/appsearch/SearchSpec.Builder#setResultCountPerPage(int)`.

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

<br />

| Parameters ||
|---|---|
| `executor` | `Executor`: Executor on which to invoke the callback. This value cannot be `null`. Callback and listener events are dispatched through this `https://developer.android.com/reference/java/util/concurrent/Executor`, providing an easy way to control which thread is used. To dispatch events through the main thread of your application, you can use `https://developer.android.com/reference/android/content/Context#getMainExecutor()`. Otherwise, provide an `https://developer.android.com/reference/java/util/concurrent/Executor` that dispatches to an appropriate thread. <br /> |
| `callback` | `Consumer`: Callback to receive the pending result of performing this operation. This value cannot be `null`. <br /> |