# InterceptingActivityFactory

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

*** ** * ** ***


```
interface InterceptingActivityFactory
```

<br />

Known direct subclasses [SingleActivityFactory](https://developer.android.com/reference/kotlin/androidx/test/runner/intercepting/SingleActivityFactory)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/test/runner/intercepting/SingleActivityFactory` | Abstract implementation of `https://developer.android.com/reference/kotlin/androidx/test/runner/intercepting/InterceptingActivityFactory` which allows to intercept only one activity at a time. |

*** ** * ** ***

> [!CAUTION]
> **This interface is deprecated.**   
>
> use `https://developer.android.com/reference/kotlin/androidx/test/ext/junit/rules/AppComponentFactoryRule` instead.

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

## Summary

| ### Public functions |
|---|---|
| `https://developer.android.com/reference/android/app/Activity.html!` | `[create](https://developer.android.com/reference/kotlin/androidx/test/runner/intercepting/InterceptingActivityFactory#create(java.lang.ClassLoader,java.lang.String,android.content.Intent))(classLoader: https://developer.android.com/reference/java/lang/ClassLoader.html!, className: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, intent: https://developer.android.com/reference/android/content/Intent.html!)` **This function is deprecated.** Deprecated in Java |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `[shouldIntercept](https://developer.android.com/reference/kotlin/androidx/test/runner/intercepting/InterceptingActivityFactory#shouldIntercept(java.lang.ClassLoader,java.lang.String,android.content.Intent))( classLoader: https://developer.android.com/reference/java/lang/ClassLoader.html!, className: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!, intent: https://developer.android.com/reference/android/content/Intent.html! )` **This function is deprecated.** Deprecated in Java |

## Public functions

### create

```
fun [create](https://developer.android.com/reference/kotlin/androidx/test/runner/intercepting/InterceptingActivityFactory#create(java.lang.ClassLoader,java.lang.String,android.content.Intent))(classLoader: ClassLoader!, className: String!, intent: Intent!): Activity!
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

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

| Parameters |
|---|---|
| `classLoader: https://developer.android.com/reference/java/lang/ClassLoader.html!` | The ClassLoader with which to instantiate the object |
| `className: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The name of the class implementing the Activity object |
| `intent: https://developer.android.com/reference/android/content/Intent.html!` | The Intent object that specified the activity class being instantiated. |

| Returns |
|---|---|
| `https://developer.android.com/reference/android/app/Activity.html!` | The newly instantiated Activity object. |

### shouldIntercept

```
fun [shouldIntercept](https://developer.android.com/reference/kotlin/androidx/test/runner/intercepting/InterceptingActivityFactory#shouldIntercept(java.lang.ClassLoader,java.lang.String,android.content.Intent))(
    classLoader: ClassLoader!,
    className: String!,
    intent: Intent!
): Boolean
```

> [!CAUTION]
> **This function is deprecated.**   
> Deprecated in Java

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.

| Parameters |
|---|---|
| `classLoader: https://developer.android.com/reference/java/lang/ClassLoader.html!` | The ClassLoader with which to instantiate the object |
| `className: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html!` | The name of the class implementing the Activity object |
| `intent: https://developer.android.com/reference/android/content/Intent.html!` | The Intent object that specified the activity class being instantiated. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | true if activity with className should be intercepted, otherwise false. |