# ResettingStubberImpl

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/ResettingStubberImpl.java+class:androidx.test.espresso.intent.ResettingStubberImpl)

*** ** * ** ***


```
public final class ResettingStubberImpl implements ResettingStubber
```

<br />

*** ** * ** ***

Implementation of `https://developer.android.com/reference/androidx/test/espresso/intent/ResettingStubber`

## Summary

| ### Public fields |
|---|---|
| `boolean` | `https://developer.android.com/reference/androidx/test/espresso/intent/ResettingStubberImpl#isInitialized()` |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/androidx/test/espresso/intent/ResettingStubberImpl#ResettingStubberImpl()()` |

| ### Public methods |
|---|---|
| `https://developer.android.com/reference/android/app/Instrumentation.ActivityResult.html` | `https://developer.android.com/reference/androidx/test/espresso/intent/ResettingStubberImpl#getActivityResultForIntent(android.content.Intent)(https://developer.android.com/reference/android/content/Intent.html intent)` Returns the first matching stubbed result for the given activity if stubbed result was set by test author. |
| `void` | `https://developer.android.com/reference/androidx/test/espresso/intent/ResettingStubberImpl#initialize()()` Marks this spy as initialized. |
| `boolean` | `https://developer.android.com/reference/androidx/test/espresso/intent/ResettingStubberImpl#isInitialized()()` |
| `void` | `https://developer.android.com/reference/androidx/test/espresso/intent/ResettingStubberImpl#reset()()` Clears state (initialization, expected responses). |
| `void` | `https://developer.android.com/reference/androidx/test/espresso/intent/ResettingStubberImpl#setActivityResultForIntent(org.hamcrest.Matcher<android.content.Intent>,android.app.Instrumentation.ActivityResult)( https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/android/content/Intent.html> matcher, https://developer.android.com/reference/android/app/Instrumentation.ActivityResult.html result )` 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. |
| `void` | `https://developer.android.com/reference/androidx/test/espresso/intent/ResettingStubberImpl#setActivityResultFunctionForIntent(org.hamcrest.Matcher<android.content.Intent>,androidx.test.espresso.intent.ActivityResultFunction)( https://junit.org/junit4/javadoc/latest/org/hamcrest/Matcher.html<https://developer.android.com/reference/android/content/Intent.html> matcher, https://developer.android.com/reference/androidx/test/espresso/intent/ActivityResultFunction result )` 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. |

## Public fields

### isInitialized

```
public boolean isInitialized
```

## Public constructors

### ResettingStubberImpl

```
public ResettingStubberImpl()
```

## Public methods

### getActivityResultForIntent

```
public Instrumentation.ActivityResult getActivityResultForIntent(Intent intent)
```

Returns the first matching stubbed result for the given activity if stubbed result was set by test author. The method searches the list of existing matcher/response pairs in reverse order of which they were entered; i.e. the last stubbing has the highest priority. If no stubbed result matching the given intent is found, `null` is returned.

Must be called on main thread.

### initialize

```
public void initialize()
```

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

### isInitialized

```
public boolean isInitialized()
```

| Returns |
|---|---|
| `boolean` | `true` if this spy is initialized |

### reset

```
public void reset()
```

Clears state (initialization, expected responses).

Must be called on main thread.

### setActivityResultForIntent

```
public void setActivityResultForIntent(
    Matcher<Intent> matcher,
    Instrumentation.ActivityResult result
)
```

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

```
public void setActivityResultFunctionForIntent(
    Matcher<Intent> matcher,
    ActivityResultFunction result
)
```

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.