# SingleActivityFactory

Summary:[Ctors](https://developer.android.com/reference/android/support/test/runner/intercepting/SingleActivityFactory#pubctors)\|[Methods](https://developer.android.com/reference/android/support/test/runner/intercepting/SingleActivityFactory#pubmethods)\|[Protected Methods](https://developer.android.com/reference/android/support/test/runner/intercepting/SingleActivityFactory#promethods)\|[Inherited Methods](https://developer.android.com/reference/android/support/test/runner/intercepting/SingleActivityFactory#inhmethods)\|[\[Expand All\]](https://developer.android.com/reference/android/support/test/runner/intercepting/SingleActivityFactory#)  

# SingleActivityFactory

| 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


abstract
class
SingleActivityFactory
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object.html)`


``


implements

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


`

|---|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html)                                                                                       ||
| ↳ | android.support.test.runner.intercepting.SingleActivityFactory\<T extends[android.app.Activity](https://developer.android.com/reference/android/app/Activity.html)\> |

<br />

*** ** * ** ***

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. Child classes are responsible for creating activity object.

## Summary

|                                                                                                                                 ### Public constructors                                                                                                                                 ||
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[SingleActivityFactory](https://developer.android.com/reference/android/support/test/runner/intercepting/SingleActivityFactory#SingleActivityFactory(java.lang.Class<T>))`(`[Class](https://developer.android.com/reference/java/lang/Class.html)`<T> activityClassToIntercept) ` |

|                                                                                                                                                                                                                                                                                                                                                               ### Public methods                                                                                                                                                                                                                                                                                                                                                                ||
|----------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` final `[Activity](https://developer.android.com/reference/android/app/Activity.html) | ` `[create](https://developer.android.com/reference/android/support/test/runner/intercepting/SingleActivityFactory#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.                         |
| ` final `[Class](https://developer.android.com/reference/java/lang/Class.html)`<T>`    | ` `[getActivityClassToIntercept](https://developer.android.com/reference/android/support/test/runner/intercepting/SingleActivityFactory#getActivityClassToIntercept())`() ` This method can be used to get the Class of activity being instantiated by this factory.                                                                                                                                                                                                                                                                                                                                                                                    |
| ` final boolean`                                                                       | ` `[shouldIntercept](https://developer.android.com/reference/android/support/test/runner/intercepting/SingleActivityFactory#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. |

|                                                                                                                                                                                                ### Protected methods                                                                                                                                                                                                 ||
|---------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` abstract T` | ` `[create](https://developer.android.com/reference/android/support/test/runner/intercepting/SingleActivityFactory#create(android.content.Intent))`(`[Intent](https://developer.android.com/reference/android/content/Intent.html)` intent) ` This method needs to be implemented by child class to create activity object for the given intent that specified the activity class being instantiated. |

| ### Inherited methods |
|-----------------------|---|
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/runner/intercepting/SingleActivityFactory#)From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object.html)` ` |-------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object.html)          | ` clone() `                                                                                | | ` boolean`                                                                          | ` equals(`[Object](https://developer.android.com/reference/java/lang/Object.html)` arg0) ` | | ` void`                                                                             | ` finalize() `                                                                             | | ` final `[Class](https://developer.android.com/reference/java/lang/Class.html)`<?>` | ` getClass() `                                                                             | | ` int`                                                                              | ` hashCode() `                                                                             | | ` final void`                                                                       | ` notify() `                                                                               | | ` final void`                                                                       | ` notifyAll() `                                                                            | | ` `[String](https://developer.android.com/reference/java/lang/String.html)          | ` toString() `                                                                             | | ` final void`                                                                       | ` wait(long arg0, int arg1) `                                                              | | ` final void`                                                                       | ` wait(long arg0) `                                                                        | | ` final void`                                                                       | ` wait() `                                                                                 | ||
| [![](https://developer.android.com/static/assets/images/styles/disclosure_down.png)](https://developer.android.com/reference/android/support/test/runner/intercepting/SingleActivityFactory#)From interface` `[android.support.test.runner.intercepting.InterceptingActivityFactory](https://developer.android.com/reference/android/support/test/runner/intercepting/InterceptingActivityFactory)` ` |-------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` 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 constructors

### SingleActivityFactory

```
SingleActivityFactory (Class<T> activityClassToIntercept)
```

<br />

<br />

|                 Parameters                 ||
|----------------------------|----------------|
| `activityClassToIntercept` | `Class` <br /> |

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

### getActivityClassToIntercept

```
Class<T> getActivityClassToIntercept ()
```

This method can be used to get the Class of activity being instantiated by this factory.

<br />

|                                                              Returns                                                               ||
|----------------------------------------------------------------------------|--------------------------------------------------------|
| [Class](https://developer.android.com/reference/java/lang/Class.html)`<T>` | Class of the activity object being instantiated <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 /> |

## Protected methods

### create

```
T create (Intent intent)
```

This method needs to be implemented by child class to create activity object for the given intent that specified the activity class being instantiated.

<br />

|                                             Parameters                                             ||
|----------|------------------------------------------------------------------------------------------|
| `intent` | `Intent`: The Intent object that specified the activity class being instantiated. <br /> |

|                       Returns                       ||
|-----|------------------------------------------------|
| `T` | The newly instantiated Activity object. <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)