# 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)

*** ** * ** ***


```
public interface InterceptingActivityFactory
```

<br />

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

|---|---|
| `https://developer.android.com/reference/androidx/test/runner/intercepting/SingleActivityFactory` | Abstract implementation of `https://developer.android.com/reference/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/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/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/androidx/test/runner/MonitoringInstrumentation#interceptActivityUsing(androidx.test.runner.intercepting.InterceptingActivityFactory)` for more details.

## Summary

| ### Public methods |
|---|---|
| `abstract https://developer.android.com/reference/android/app/Activity.html` | `[create](https://developer.android.com/reference/androidx/test/runner/intercepting/InterceptingActivityFactory#create(java.lang.ClassLoader,java.lang.String,android.content.Intent))(https://developer.android.com/reference/java/lang/ClassLoader.html classLoader, https://developer.android.com/reference/java/lang/String.html className, https://developer.android.com/reference/android/content/Intent.html intent)` **This method is deprecated.** Deprecated in Java |
| `abstract boolean` | `[shouldIntercept](https://developer.android.com/reference/androidx/test/runner/intercepting/InterceptingActivityFactory#shouldIntercept(java.lang.ClassLoader,java.lang.String,android.content.Intent))( https://developer.android.com/reference/java/lang/ClassLoader.html classLoader, https://developer.android.com/reference/java/lang/String.html className, https://developer.android.com/reference/android/content/Intent.html intent )` **This method is deprecated.** Deprecated in Java |

## Public methods

### create

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

> [!CAUTION]
> **This method 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 |
|---|---|
| `https://developer.android.com/reference/java/lang/ClassLoader.html classLoader` | The ClassLoader with which to instantiate the object |
| `https://developer.android.com/reference/java/lang/String.html className` | The name of the class implementing the Activity object |
| `https://developer.android.com/reference/android/content/Intent.html intent` | 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

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

> [!CAUTION]
> **This method 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 |
|---|---|
| `https://developer.android.com/reference/java/lang/ClassLoader.html classLoader` | The ClassLoader with which to instantiate the object |
| `https://developer.android.com/reference/java/lang/String.html className` | The name of the class implementing the Activity object |
| `https://developer.android.com/reference/android/content/Intent.html intent` | The Intent object that specified the activity class being instantiated. |

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