# IntentStubber

Summary:[Methods](https://developer.android.com/reference/android/support/test/runner/intent/IntentStubber#pubmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/test/runner/intent/IntentStubber#)  

# IntentStubber

| This package is part of the Android[support library](https://developer.android.com/topic/libraries/support-library)which is no longer maintained. The support library has been superseded by[AndroidX](https://developer.android.com/jetpack/androidx)which is part of[Jetpack](https://developer.android.com/jetpack). We recommend using the AndroidX libraries in all new projects. You should also consider[migrating](https://developer.android.com/jetpack/androidx/migrate)existing projects to AndroidX. To find the AndroidX class that maps to this deprecated class, see the AndroidX support library[class mappings](https://developer.android.com/jetpack/androidx/migrate/class-mappings).

`
public


interface
IntentStubber
`  
`


`

|--------------------------------------------------|
| android.support.test.runner.intent.IntentStubber |

|---|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/runner/intent/IntentStubber#)Known Indirect Subclasses [ResettingStubber](https://developer.android.com/reference/android/support/test/espresso/intent/ResettingStubber),[ResettingStubberImpl](https://developer.android.com/reference/android/support/test/espresso/intent/ResettingStubberImpl) |---------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------| | [ResettingStubber](https://developer.android.com/reference/android/support/test/espresso/intent/ResettingStubber)         | A sneaky singleton object used to respond to intents with fake responses.                                                          | | [ResettingStubberImpl](https://developer.android.com/reference/android/support/test/espresso/intent/ResettingStubberImpl) | Implementation of[ResettingStubber](https://developer.android.com/reference/android/support/test/espresso/intent/ResettingStubber) | ||

<br />

*** ** * ** ***

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

Retrieve instances of the stubber through[IntentStubberRegistry](https://developer.android.com/reference/android/support/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 `[Instrumentation.ActivityResult](https://developer.android.com/reference/android/app/Instrumentation.ActivityResult.html) | ` `[getActivityResultForIntent](https://developer.android.com/reference/android/support/test/runner/intent/IntentStubber#getActivityResultForIntent(android.content.Intent))`(`[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

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

<br />

|        Parameters         ||
|----------|-----------------|
| `intent` | `Intent` <br /> |

|                                                              Returns                                                              ||
|---------------------------------------------------------------------------------------------------------------------------|--------|
| [Instrumentation.ActivityResult](https://developer.android.com/reference/android/app/Instrumentation.ActivityResult.html) | <br /> |

-

  ## Interfaces

  - [IntentCallback](https://developer.android.com/reference/android/support/test/runner/intent/IntentCallback)
  - [IntentMonitor](https://developer.android.com/reference/android/support/test/runner/intent/IntentMonitor)
  - [IntentStubber](https://developer.android.com/reference/android/support/test/runner/intent/IntentStubber)
-

  ## Classes

  - [IntentMonitorRegistry](https://developer.android.com/reference/android/support/test/runner/intent/IntentMonitorRegistry)
  - [IntentStubberRegistry](https://developer.android.com/reference/android/support/test/runner/intent/IntentStubberRegistry)