# IntentStubber

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

*** ** * ** ***


```
public interface IntentStubber
```

<br />

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

|---|---|
| `https://developer.android.com/reference/androidx/test/espresso/intent/ResettingStubber` | A sneaky singleton object used to respond to intents with fake responses. |

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

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

*** ** * ** ***

Interface to intercept activity launch for a given `https://developer.android.com/reference/android/content/Intent.html` and stub `https://developer.android.com/reference/android/app/Instrumentation.ActivityResult.html` its response.

Retrieve instances of the stubber through `https://developer.android.com/reference/androidx/test/runner/intent/IntentStubberRegistry`

Stubbing intents requires support from Instrumentation, therefore do not expect an instance to be present under any arbitrary instrumentation.

## Summary

| ### Public methods |
|---|---|
| `abstract https://developer.android.com/reference/android/app/Instrumentation.ActivityResult.html` | `https://developer.android.com/reference/androidx/test/runner/intent/IntentStubber#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. |

## Public methods

### getActivityResultForIntent

```
abstract 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.