# InterceptingActivityFactory

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

# InterceptingActivityFactory

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


`


`

|----------------------------------------------------------------------|
| android.support.test.runner.intercepting.InterceptingActivityFactory |

|---|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/runner/intercepting/InterceptingActivityFactory#)Known Indirect Subclasses [SingleActivityFactory](https://developer.android.com/reference/android/support/test/runner/intercepting/SingleActivityFactory)\<T extends [Activity](https://developer.android.com/reference/android/app/Activity.html)\> |----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [SingleActivityFactory](https://developer.android.com/reference/android/support/test/runner/intercepting/SingleActivityFactory)\<T extends [Activity](https://developer.android.com/reference/android/app/Activity.html)\> | Abstract implementation of [InterceptingActivityFactory](https://developer.android.com/reference/android/support/test/runner/intercepting/InterceptingActivityFactory) which allows to intercept only one activity at a time. | ||

<br />

*** ** * ** ***

Implement this interface to provide custom implementation of Activity under test. It is used by
[newActivity(ClassLoader, String, Intent)](https://developer.android.com/reference/android/support/test/runner/MonitoringInstrumentation#newActivity(java.lang.ClassLoader, java.lang.String, android.content.Intent)) to create instance of the activity under test. Please see [interceptActivityUsing(InterceptingActivityFactory)](https://developer.android.com/reference/android/support/test/runner/MonitoringInstrumentation#interceptActivityUsing(android.support.test.runner.intercepting.InterceptingActivityFactory))
for more details.

## Summary

|                                                                                                                                                                                                                                                                                                                                                                    ### Public methods                                                                                                                                                                                                                                                                                                                                                                    ||
|-------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract `[Activity](https://developer.android.com/reference/android/app/Activity.html) | ` `[create](https://developer.android.com/reference/android/support/test/runner/intercepting/InterceptingActivityFactory#create(java.lang.ClassLoader, java.lang.String, android.content.Intent))`(`[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader.html)` classLoader, `[String](https://developer.android.com/reference/java/lang/String.html)` className, `[Intent](https://developer.android.com/reference/android/content/Intent.html)` intent) ` This method can be used to provide activity instance while intercepting activity creation for a particular activity in response to a given intent.                         |
| ` abstract boolean`                                                                       | ` `[shouldIntercept](https://developer.android.com/reference/android/support/test/runner/intercepting/InterceptingActivityFactory#shouldIntercept(java.lang.ClassLoader, java.lang.String, android.content.Intent))`(`[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader.html)` classLoader, `[String](https://developer.android.com/reference/java/lang/String.html)` className, `[Intent](https://developer.android.com/reference/android/content/Intent.html)` intent) ` This method can be used to know whether activity instance creation should be intercepted or not for a particular activity in response to a given intent. |

## Public methods

### create

```
Activity create (ClassLoader classLoader, 
                String className, 
                Intent intent)
```

This method can be used to provide activity instance while intercepting activity creation for a
particular activity in response to a given intent.

<br />

|                                               Parameters                                                ||
|---------------|------------------------------------------------------------------------------------------|
| `classLoader` | `ClassLoader`: The ClassLoader with which to instantiate the object <br />               |
| `className`   | `String`: The name of the class implementing the Activity object <br />                  |
| `intent`      | `Intent`: The Intent object that specified the activity class being instantiated. <br /> |

|                                                            Returns                                                            ||
|-------------------------------------------------------------------------------|------------------------------------------------|
| [Activity](https://developer.android.com/reference/android/app/Activity.html) | The newly instantiated Activity object. <br /> |

### shouldIntercept

```
boolean shouldIntercept (ClassLoader classLoader, 
                String className, 
                Intent intent)
```

This method can be used to know whether activity instance creation should be intercepted or not
for a particular activity in response to a given intent.

<br />

|                                               Parameters                                                ||
|---------------|------------------------------------------------------------------------------------------|
| `classLoader` | `ClassLoader`: The ClassLoader with which to instantiate the object <br />               |
| `className`   | `String`: The name of the class implementing the Activity object <br />                  |
| `intent`      | `Intent`: The Intent object that specified the activity class being instantiated. <br /> |

|                                          Returns                                          ||
|-----------|--------------------------------------------------------------------------------|
| `boolean` | true if activity with className should be intercepted, otherwise false. <br /> |

-

  ## Interfaces

  - [InterceptingActivityFactory](https://developer.android.com/reference/android/support/test/runner/intercepting/InterceptingActivityFactory)
-

  ## Classes

  - [SingleActivityFactory](https://developer.android.com/reference/android/support/test/runner/intercepting/SingleActivityFactory)