# AppComponentFactory

# AppComponentFactory

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/app/AppComponentFactory.java+class:androidx.core.app.AppComponentFactory)  
Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/app/AppComponentFactory "View this page in Java")

<br />

```
@RequiresApi(value = 28)
class AppComponentFactory : AppComponentFactory
```

<br />

|---|---|-------------------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html)                                                  |||
| ↳ | [android.app.AppComponentFactory](https://developer.android.com/reference/android/app/AppComponentFactory.html)                  ||
|   | ↳ | [androidx.core.app.AppComponentFactory](https://developer.android.com/reference/kotlin/androidx/core/app/AppComponentFactory) |

*** ** * ** ***

Version of[android.app.AppComponentFactory](https://developer.android.com/reference/android/app/AppComponentFactory.html)that works with androidx libraries. Note: This will only work on API 28+ and does not backport AppComponentFactory functionality.

## Summary

|                                                        ### Public constructors                                                        |
|---------------------------------------------------------------------------------------------------------------------------------------|
| [AppComponentFactory](https://developer.android.com/reference/kotlin/androidx/core/app/AppComponentFactory#AppComponentFactory())`()` |

|                                        ### Public functions                                         |
|-----------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| [Activity](https://developer.android.com/reference/android/app/Activity.html)                       | [instantiateActivity](https://developer.android.com/reference/kotlin/androidx/core/app/AppComponentFactory#instantiateActivity(java.lang.ClassLoader,java.lang.String,android.content.Intent))`(cl: `[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader.html)`, className: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`, intent: `[Intent](https://developer.android.com/reference/android/content/Intent.html)`?)`                                                                                     |
| [Activity](https://developer.android.com/reference/android/app/Activity.html)                       | [instantiateActivityCompat](https://developer.android.com/reference/kotlin/androidx/core/app/AppComponentFactory#instantiateActivityCompat(java.lang.ClassLoader,java.lang.String,android.content.Intent))`(` ` cl: `[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader.html)`,` ` className: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`,` ` intent: `[Intent](https://developer.android.com/reference/android/content/Intent.html)`?` `)` Allows application to override the creation of activities. |
| [Application](https://developer.android.com/reference/android/app/Application.html)                 | [instantiateApplication](https://developer.android.com/reference/kotlin/androidx/core/app/AppComponentFactory#instantiateApplication(java.lang.ClassLoader,java.lang.String))`(cl: `[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader.html)`, className: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)`                                                                                                                                                                                                |
| [Application](https://developer.android.com/reference/android/app/Application.html)                 | [instantiateApplicationCompat](https://developer.android.com/reference/kotlin/androidx/core/app/AppComponentFactory#instantiateApplicationCompat(java.lang.ClassLoader,java.lang.String))`(cl: `[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader.html)`, className: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)` Allows application to override the creation of the application object.                                                                                                             |
| [ContentProvider](https://developer.android.com/reference/android/content/ContentProvider.html)     | [instantiateProvider](https://developer.android.com/reference/kotlin/androidx/core/app/AppComponentFactory#instantiateProvider(java.lang.ClassLoader,java.lang.String))`(cl: `[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader.html)`, className: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)`                                                                                                                                                                                                      |
| [ContentProvider](https://developer.android.com/reference/android/content/ContentProvider.html)     | [instantiateProviderCompat](https://developer.android.com/reference/kotlin/androidx/core/app/AppComponentFactory#instantiateProviderCompat(java.lang.ClassLoader,java.lang.String))`(cl: `[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader.html)`, className: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`)` Allows application to override the creation of providers.                                                                                                                                |
| [BroadcastReceiver](https://developer.android.com/reference/android/content/BroadcastReceiver.html) | [instantiateReceiver](https://developer.android.com/reference/kotlin/androidx/core/app/AppComponentFactory#instantiateReceiver(java.lang.ClassLoader,java.lang.String,android.content.Intent))`(cl: `[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader.html)`, className: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`, intent: `[Intent](https://developer.android.com/reference/android/content/Intent.html)`?)`                                                                                     |
| [BroadcastReceiver](https://developer.android.com/reference/android/content/BroadcastReceiver.html) | [instantiateReceiverCompat](https://developer.android.com/reference/kotlin/androidx/core/app/AppComponentFactory#instantiateReceiverCompat(java.lang.ClassLoader,java.lang.String,android.content.Intent))`(` ` cl: `[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader.html)`,` ` className: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`,` ` intent: `[Intent](https://developer.android.com/reference/android/content/Intent.html)`?` `)` Allows application to override the creation of receivers.  |
| [Service](https://developer.android.com/reference/android/app/Service.html)                         | [instantiateService](https://developer.android.com/reference/kotlin/androidx/core/app/AppComponentFactory#instantiateService(java.lang.ClassLoader,java.lang.String,android.content.Intent))`(cl: `[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader.html)`, className: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`, intent: `[Intent](https://developer.android.com/reference/android/content/Intent.html)`?)`                                                                                       |
| [Service](https://developer.android.com/reference/android/app/Service.html)                         | [instantiateServiceCompat](https://developer.android.com/reference/kotlin/androidx/core/app/AppComponentFactory#instantiateServiceCompat(java.lang.ClassLoader,java.lang.String,android.content.Intent))`(` ` cl: `[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader.html)`,` ` className: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`,` ` intent: `[Intent](https://developer.android.com/reference/android/content/Intent.html)`?` `)` Allows application to override the creation of services.     |

|                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             ### Inherited functions                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| From[android.app.AppComponentFactory](https://developer.android.com/reference/android/app/AppComponentFactory.html) |--------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader.html)`!` | [instantiateClassLoader](https://developer.android.com/reference/android/app/AppComponentFactory.html#instantiateClassLoader(java.lang.ClassLoader, android.content.pm.ApplicationInfo))`(cl: `[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader.html)`!, aInfo: `[ApplicationInfo](https://developer.android.com/reference/android/content/pm/ApplicationInfo.html)`!)` | |

## Public constructors

### AppComponentFactory

Added in 1.1.0  

```
AppComponentFactory()
```  

## Public functions

### instantiateActivity

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun instantiateActivity(cl: ClassLoader, className: String, intent: Intent?): Activity
```  

|                                                      Throws                                                       |
|-------------------------------------------------------------------------------------------------------------------|---|
| [java.lang.InstantiationException](https://developer.android.com/reference/java/lang/InstantiationException.html) |   |
| [java.lang.IllegalAccessException](https://developer.android.com/reference/java/lang/IllegalAccessException.html) |   |
| [java.lang.ClassNotFoundException](https://developer.android.com/reference/java/lang/ClassNotFoundException.html) |   |

|                                                                                                  See also                                                                                                  |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [instantiateActivityCompat](https://developer.android.com/reference/kotlin/androidx/core/app/AppComponentFactory#instantiateActivityCompat(java.lang.ClassLoader,java.lang.String,android.content.Intent)) |   |

### instantiateActivityCompat

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun instantiateActivityCompat(
    cl: ClassLoader,
    className: String,
    intent: Intent?
): Activity
```

Allows application to override the creation of activities. This can be used to perform things such as dependency injection or class loader changes to these classes.

This method is only intended to provide a hook for instantiation. It does not provide earlier access to the Activity object. The returned object will not be initialized as a Context yet and should not be used to interact with other android APIs.  

|                                           Parameters                                           |
|------------------------------------------------------------------------------------------------|---------------------------------------------------|
| `cl: `[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader.html)        | The default classloader to use for instantiation. |
| `className: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The class to be instantiated.                     |
| `intent: `[Intent](https://developer.android.com/reference/android/content/Intent.html)`?`     | Intent creating the class.                        |

|                                                      Throws                                                       |
|-------------------------------------------------------------------------------------------------------------------|---|
| [java.lang.InstantiationException](https://developer.android.com/reference/java/lang/InstantiationException.html) |   |
| [java.lang.IllegalAccessException](https://developer.android.com/reference/java/lang/IllegalAccessException.html) |   |
| [java.lang.ClassNotFoundException](https://developer.android.com/reference/java/lang/ClassNotFoundException.html) |   |

### instantiateApplication

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun instantiateApplication(cl: ClassLoader, className: String): Application
```  

|                                                      Throws                                                       |
|-------------------------------------------------------------------------------------------------------------------|---|
| [java.lang.InstantiationException](https://developer.android.com/reference/java/lang/InstantiationException.html) |   |
| [java.lang.IllegalAccessException](https://developer.android.com/reference/java/lang/IllegalAccessException.html) |   |
| [java.lang.ClassNotFoundException](https://developer.android.com/reference/java/lang/ClassNotFoundException.html) |   |

|                                                                                         See also                                                                                          |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [instantiateApplicationCompat](https://developer.android.com/reference/kotlin/androidx/core/app/AppComponentFactory#instantiateApplicationCompat(java.lang.ClassLoader,java.lang.String)) |   |

### instantiateApplicationCompat

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun instantiateApplicationCompat(cl: ClassLoader, className: String): Application
```

Allows application to override the creation of the application object. This can be used to perform things such as dependency injection or class loader changes to these classes.

This method is only intended to provide a hook for instantiation. It does not provide earlier access to the Application object. The returned object will not be initialized as a Context yet and should not be used to interact with other android APIs.  

|                                           Parameters                                           |
|------------------------------------------------------------------------------------------------|---------------------------------------------------|
| `cl: `[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader.html)        | The default classloader to use for instantiation. |
| `className: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The class to be instantiated.                     |

|                                                      Throws                                                       |
|-------------------------------------------------------------------------------------------------------------------|---|
| [java.lang.InstantiationException](https://developer.android.com/reference/java/lang/InstantiationException.html) |   |
| [java.lang.IllegalAccessException](https://developer.android.com/reference/java/lang/IllegalAccessException.html) |   |
| [java.lang.ClassNotFoundException](https://developer.android.com/reference/java/lang/ClassNotFoundException.html) |   |

### instantiateProvider

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun instantiateProvider(cl: ClassLoader, className: String): ContentProvider
```  

|                                                      Throws                                                       |
|-------------------------------------------------------------------------------------------------------------------|---|
| [java.lang.InstantiationException](https://developer.android.com/reference/java/lang/InstantiationException.html) |   |
| [java.lang.IllegalAccessException](https://developer.android.com/reference/java/lang/IllegalAccessException.html) |   |
| [java.lang.ClassNotFoundException](https://developer.android.com/reference/java/lang/ClassNotFoundException.html) |   |

|                                                                                      See also                                                                                       |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [instantiateProviderCompat](https://developer.android.com/reference/kotlin/androidx/core/app/AppComponentFactory#instantiateProviderCompat(java.lang.ClassLoader,java.lang.String)) |   |

### instantiateProviderCompat

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun instantiateProviderCompat(cl: ClassLoader, className: String): ContentProvider
```

Allows application to override the creation of providers. This can be used to perform things such as dependency injection or class loader changes to these classes.

This method is only intended to provide a hook for instantiation. It does not provide earlier access to the ContentProvider object. The returned object will not be initialized with a Context yet and should not be used to interact with other android APIs.  

|                                           Parameters                                           |
|------------------------------------------------------------------------------------------------|---------------------------------------------------|
| `cl: `[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader.html)        | The default classloader to use for instantiation. |
| `className: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The class to be instantiated.                     |

|                                                      Throws                                                       |
|-------------------------------------------------------------------------------------------------------------------|---|
| [java.lang.InstantiationException](https://developer.android.com/reference/java/lang/InstantiationException.html) |   |
| [java.lang.IllegalAccessException](https://developer.android.com/reference/java/lang/IllegalAccessException.html) |   |
| [java.lang.ClassNotFoundException](https://developer.android.com/reference/java/lang/ClassNotFoundException.html) |   |

### instantiateReceiver

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun instantiateReceiver(cl: ClassLoader, className: String, intent: Intent?): BroadcastReceiver
```  

|                                                      Throws                                                       |
|-------------------------------------------------------------------------------------------------------------------|---|
| [java.lang.InstantiationException](https://developer.android.com/reference/java/lang/InstantiationException.html) |   |
| [java.lang.IllegalAccessException](https://developer.android.com/reference/java/lang/IllegalAccessException.html) |   |
| [java.lang.ClassNotFoundException](https://developer.android.com/reference/java/lang/ClassNotFoundException.html) |   |

|                                                                                                  See also                                                                                                  |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [instantiateReceiverCompat](https://developer.android.com/reference/kotlin/androidx/core/app/AppComponentFactory#instantiateReceiverCompat(java.lang.ClassLoader,java.lang.String,android.content.Intent)) |   |

### instantiateReceiverCompat

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun instantiateReceiverCompat(
    cl: ClassLoader,
    className: String,
    intent: Intent?
): BroadcastReceiver
```

Allows application to override the creation of receivers. This can be used to perform things such as dependency injection or class loader changes to these classes.  

|                                           Parameters                                           |
|------------------------------------------------------------------------------------------------|---------------------------------------------------|
| `cl: `[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader.html)        | The default classloader to use for instantiation. |
| `className: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The class to be instantiated.                     |
| `intent: `[Intent](https://developer.android.com/reference/android/content/Intent.html)`?`     | Intent creating the class.                        |

|                                                      Throws                                                       |
|-------------------------------------------------------------------------------------------------------------------|---|
| [java.lang.InstantiationException](https://developer.android.com/reference/java/lang/InstantiationException.html) |   |
| [java.lang.IllegalAccessException](https://developer.android.com/reference/java/lang/IllegalAccessException.html) |   |
| [java.lang.ClassNotFoundException](https://developer.android.com/reference/java/lang/ClassNotFoundException.html) |   |

### instantiateService

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun instantiateService(cl: ClassLoader, className: String, intent: Intent?): Service
```  

|                                                      Throws                                                       |
|-------------------------------------------------------------------------------------------------------------------|---|
| [java.lang.InstantiationException](https://developer.android.com/reference/java/lang/InstantiationException.html) |   |
| [java.lang.IllegalAccessException](https://developer.android.com/reference/java/lang/IllegalAccessException.html) |   |
| [java.lang.ClassNotFoundException](https://developer.android.com/reference/java/lang/ClassNotFoundException.html) |   |

|                                                                                                 See also                                                                                                 |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| [instantiateServiceCompat](https://developer.android.com/reference/kotlin/androidx/core/app/AppComponentFactory#instantiateServiceCompat(java.lang.ClassLoader,java.lang.String,android.content.Intent)) |   |

### instantiateServiceCompat

Added in[1.1.0](https://developer.android.com/jetpack/androidx/releases/core#1.1.0)  

```
fun instantiateServiceCompat(
    cl: ClassLoader,
    className: String,
    intent: Intent?
): Service
```

Allows application to override the creation of services. This can be used to perform things such as dependency injection or class loader changes to these classes.

This method is only intended to provide a hook for instantiation. It does not provide earlier access to the Service object. The returned object will not be initialized as a Context yet and should not be used to interact with other android APIs.  

|                                           Parameters                                           |
|------------------------------------------------------------------------------------------------|---------------------------------------------------|
| `cl: `[ClassLoader](https://developer.android.com/reference/java/lang/ClassLoader.html)        | The default classloader to use for instantiation. |
| `className: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html) | The class to be instantiated.                     |
| `intent: `[Intent](https://developer.android.com/reference/android/content/Intent.html)`?`     | Intent creating the class.                        |

|                                                      Throws                                                       |
|-------------------------------------------------------------------------------------------------------------------|---|
| [java.lang.InstantiationException](https://developer.android.com/reference/java/lang/InstantiationException.html) |   |
| [java.lang.IllegalAccessException](https://developer.android.com/reference/java/lang/IllegalAccessException.html) |   |
| [java.lang.ClassNotFoundException](https://developer.android.com/reference/java/lang/ClassNotFoundException.html) |   |