# ResettingStubber

# ResettingStubber

Artifact:[androidx.test.espresso:espresso-intents](https://developer.android.com/jetpack/androidx/releases/test-espresso)  
[View Source](https://cs.android.com/search?q=file:androidx/test/espresso/intent/ResettingStubber.java+class:androidx.test.espresso.intent.ResettingStubber)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/test/espresso/intent/ResettingStubber "View this page in Java")

<br />

```
interface ResettingStubber : IntentStubber
```

<br />

Known direct subclasses  
[ResettingStubberImpl](https://developer.android.com/reference/kotlin/androidx/test/espresso/intent/ResettingStubberImpl)  

|---------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------|
| [ResettingStubberImpl](https://developer.android.com/reference/kotlin/androidx/test/espresso/intent/ResettingStubberImpl) | Implementation of[ResettingStubber](https://developer.android.com/reference/kotlin/androidx/test/espresso/intent/ResettingStubber) |

*** ** * ** ***

A sneaky singleton object used to respond to intents with fake responses. This interface is not meant for public consumption. Test authors should use[Intents](https://developer.android.com/reference/kotlin/androidx/test/espresso/intent/Intents)instead.

## Summary

|                                ### Public functions                                 |
|-------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | [initialize](https://developer.android.com/reference/kotlin/androidx/test/espresso/intent/ResettingStubber#initialize())`()` Marks this spy as initialized.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | [isInitialized](https://developer.android.com/reference/kotlin/androidx/test/espresso/intent/ResettingStubber#isInitialized())`()`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | [reset](https://developer.android.com/reference/kotlin/androidx/test/espresso/intent/ResettingStubber#reset())`()` Clears state (initialization, expected responses).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | [setActivityResultForIntent](https://developer.android.com/reference/kotlin/androidx/test/espresso/intent/ResettingStubber#setActivityResultForIntent(org.hamcrest.Matcher<android.content.Intent>,android.app.Instrumentation.ActivityResult))`(` ` matcher: `[Matcher](https://junit.org/junit4/javadoc/4.12/org/hamcrest/Matcher.html)`<`[Intent](https://developer.android.com/reference/android/content/Intent.html)`!>!,` ` result: `[Instrumentation.ActivityResult](https://developer.android.com/reference/android/app/Instrumentation.ActivityResult.html)`!` `)` Sets the result that will be returned to the intent sender (if the sender expects the result), next time an intent matched by the given matcher is launched.                                    |
| [Unit](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html)       | [setActivityResultFunctionForIntent](https://developer.android.com/reference/kotlin/androidx/test/espresso/intent/ResettingStubber#setActivityResultFunctionForIntent(org.hamcrest.Matcher<android.content.Intent>,androidx.test.espresso.intent.ActivityResultFunction))`(` ` matcher: `[Matcher](https://junit.org/junit4/javadoc/4.12/org/hamcrest/Matcher.html)`<`[Intent](https://developer.android.com/reference/android/content/Intent.html)`!>!,` ` result: `[ActivityResultFunction](https://developer.android.com/reference/kotlin/androidx/test/espresso/intent/ActivityResultFunction)`!` `)` Sets a result function that will be called by the intent sender (if the sender expects the result), next time an intent matched by the given matcher is launched. |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              ### Inherited functions                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From[androidx.test.runner.intent.IntentStubber](https://developer.android.com/reference/kotlin/androidx/test/runner/intent/IntentStubber) |------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [Instrumentation.ActivityResult](https://developer.android.com/reference/android/app/Instrumentation.ActivityResult.html)`!` | [getActivityResultForIntent](https://developer.android.com/reference/kotlin/androidx/test/runner/intent/IntentStubber#getActivityResultForIntent(android.content.Intent))`(intent: `[Intent](https://developer.android.com/reference/android/content/Intent.html)`!)` Returns the first matching stubbed result for the given activity if stubbed result was set by test author. | |

## Public functions

### initialize

```
fun initialize(): Unit
```

Marks this spy as initialized. Once initialized, ResettingStubber begins recording intents and provides intent stubbing.  

### isInitialized

```
fun isInitialized(): Boolean
```  

|                                       Returns                                       |
|-------------------------------------------------------------------------------------|----------------------------------|
| [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html) | `true`if this spy is initialized |

### reset

```
fun reset(): Unit
```

Clears state (initialization, expected responses).

Must be called on main thread.  

### setActivityResultForIntent

```
fun setActivityResultForIntent(
    matcher: Matcher<Intent!>!,
    result: Instrumentation.ActivityResult!
): Unit
```

Sets the result that will be returned to the intent sender (if the sender expects the result), next time an intent matched by the given matcher is launched.  

### setActivityResultFunctionForIntent

```
fun setActivityResultFunctionForIntent(
    matcher: Matcher<Intent!>!,
    result: ActivityResultFunction!
): Unit
```

Sets a result function that will be called by the intent sender (if the sender expects the result), next time an intent matched by the given matcher is launched.