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

*** ** * ** ***


```
@RequiresApi(value = 28)
public class AppComponentFactory extends AppComponentFactory
```

<br />

|---|---|---|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object.html) |||
| ↳ | [android.app.AppComponentFactory](https://developer.android.com/reference/android/app/AppComponentFactory.html) ||
|   | ↳ | [androidx.core.app.AppComponentFactory](https://developer.android.com/reference/androidx/core/app/AppComponentFactory) |

*** ** * ** ***

Version of `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 |
|---|
| `https://developer.android.com/reference/androidx/core/app/AppComponentFactory#AppComponentFactory()()` |

| ### Public methods |
|---|---|
| `final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Activity.html` | `https://developer.android.com/reference/androidx/core/app/AppComponentFactory#instantiateActivity(java.lang.ClassLoader,java.lang.String,android.content.Intent)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/ClassLoader.html cl, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html className, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/Intent.html intent )` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Activity.html` | `https://developer.android.com/reference/androidx/core/app/AppComponentFactory#instantiateActivityCompat(java.lang.ClassLoader,java.lang.String,android.content.Intent)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/ClassLoader.html cl, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html className, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/Intent.html intent )` Allows application to override the creation of activities. |
| `final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Application.html` | `https://developer.android.com/reference/androidx/core/app/AppComponentFactory#instantiateApplication(java.lang.ClassLoader,java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/ClassLoader.html cl, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html className)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Application.html` | `https://developer.android.com/reference/androidx/core/app/AppComponentFactory#instantiateApplicationCompat(java.lang.ClassLoader,java.lang.String)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/ClassLoader.html cl, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html className )` Allows application to override the creation of the application object. |
| `final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/ContentProvider.html` | `https://developer.android.com/reference/androidx/core/app/AppComponentFactory#instantiateProvider(java.lang.ClassLoader,java.lang.String)(@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/ClassLoader.html cl, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html className)` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/ContentProvider.html` | `https://developer.android.com/reference/androidx/core/app/AppComponentFactory#instantiateProviderCompat(java.lang.ClassLoader,java.lang.String)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/ClassLoader.html cl, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html className )` Allows application to override the creation of providers. |
| `final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/BroadcastReceiver.html` | `https://developer.android.com/reference/androidx/core/app/AppComponentFactory#instantiateReceiver(java.lang.ClassLoader,java.lang.String,android.content.Intent)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/ClassLoader.html cl, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html className, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/Intent.html intent )` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/content/BroadcastReceiver.html` | `https://developer.android.com/reference/androidx/core/app/AppComponentFactory#instantiateReceiverCompat(java.lang.ClassLoader,java.lang.String,android.content.Intent)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/ClassLoader.html cl, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html className, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/Intent.html intent )` Allows application to override the creation of receivers. |
| `final @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Service.html` | `https://developer.android.com/reference/androidx/core/app/AppComponentFactory#instantiateService(java.lang.ClassLoader,java.lang.String,android.content.Intent)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/ClassLoader.html cl, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html className, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/Intent.html intent )` |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/android/app/Service.html` | `https://developer.android.com/reference/androidx/core/app/AppComponentFactory#instantiateServiceCompat(java.lang.ClassLoader,java.lang.String,android.content.Intent)( @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/ClassLoader.html cl, @https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html className, @https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/Intent.html intent )` Allows application to override the creation of services. |

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

## Public constructors

### AppComponentFactory

Added in 1.1.0

```
public AppComponentFactory()
```

## Public methods

### instantiateActivity

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

```
public final @NonNull Activity instantiateActivity(
    @NonNull ClassLoader cl,
    @NonNull String className,
    @Nullable Intent intent
)
```

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/InstantiationException.html` |   |
| `https://developer.android.com/reference/java/lang/IllegalAccessException.html` |   |
| `https://developer.android.com/reference/java/lang/ClassNotFoundException.html` |   |

| See also |
|---|---|
| `https://developer.android.com/reference/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)

```
public @NonNull Activity instantiateActivityCompat(
    @NonNull ClassLoader cl,
    @NonNull String className,
    @Nullable Intent intent
)
```

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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/ClassLoader.html cl` | The default classloader to use for instantiation. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html className` | The class to be instantiated. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/Intent.html intent` | Intent creating the class. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/InstantiationException.html` |   |
| `https://developer.android.com/reference/java/lang/IllegalAccessException.html` |   |
| `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)

```
public final @NonNull Application instantiateApplication(@NonNull ClassLoader cl, @NonNull String className)
```

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/InstantiationException.html` |   |
| `https://developer.android.com/reference/java/lang/IllegalAccessException.html` |   |
| `https://developer.android.com/reference/java/lang/ClassNotFoundException.html` |   |

| See also |
|---|---|
| `https://developer.android.com/reference/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)

```
public @NonNull Application instantiateApplicationCompat(
    @NonNull ClassLoader cl,
    @NonNull String className
)
```

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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/ClassLoader.html cl` | The default classloader to use for instantiation. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html className` | The class to be instantiated. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/InstantiationException.html` |   |
| `https://developer.android.com/reference/java/lang/IllegalAccessException.html` |   |
| `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)

```
public final @NonNull ContentProvider instantiateProvider(@NonNull ClassLoader cl, @NonNull String className)
```

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/InstantiationException.html` |   |
| `https://developer.android.com/reference/java/lang/IllegalAccessException.html` |   |
| `https://developer.android.com/reference/java/lang/ClassNotFoundException.html` |   |

| See also |
|---|---|
| `https://developer.android.com/reference/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)

```
public @NonNull ContentProvider instantiateProviderCompat(
    @NonNull ClassLoader cl,
    @NonNull String className
)
```

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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/ClassLoader.html cl` | The default classloader to use for instantiation. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html className` | The class to be instantiated. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/InstantiationException.html` |   |
| `https://developer.android.com/reference/java/lang/IllegalAccessException.html` |   |
| `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)

```
public final @NonNull BroadcastReceiver instantiateReceiver(
    @NonNull ClassLoader cl,
    @NonNull String className,
    @Nullable Intent intent
)
```

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/InstantiationException.html` |   |
| `https://developer.android.com/reference/java/lang/IllegalAccessException.html` |   |
| `https://developer.android.com/reference/java/lang/ClassNotFoundException.html` |   |

| See also |
|---|---|
| `https://developer.android.com/reference/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)

```
public @NonNull BroadcastReceiver instantiateReceiverCompat(
    @NonNull ClassLoader cl,
    @NonNull String className,
    @Nullable Intent intent
)
```

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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/ClassLoader.html cl` | The default classloader to use for instantiation. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html className` | The class to be instantiated. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/Intent.html intent` | Intent creating the class. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/InstantiationException.html` |   |
| `https://developer.android.com/reference/java/lang/IllegalAccessException.html` |   |
| `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)

```
public final @NonNull Service instantiateService(
    @NonNull ClassLoader cl,
    @NonNull String className,
    @Nullable Intent intent
)
```

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/InstantiationException.html` |   |
| `https://developer.android.com/reference/java/lang/IllegalAccessException.html` |   |
| `https://developer.android.com/reference/java/lang/ClassNotFoundException.html` |   |

| See also |
|---|---|
| `https://developer.android.com/reference/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)

```
public @NonNull Service instantiateServiceCompat(
    @NonNull ClassLoader cl,
    @NonNull String className,
    @Nullable Intent intent
)
```

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 |
|---|---|
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/ClassLoader.html cl` | The default classloader to use for instantiation. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/NonNull.html https://developer.android.com/reference/java/lang/String.html className` | The class to be instantiated. |
| `@https://jspecify.dev/docs/api/org/jspecify/annotations/Nullable.html https://developer.android.com/reference/android/content/Intent.html intent` | Intent creating the class. |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/InstantiationException.html` |   |
| `https://developer.android.com/reference/java/lang/IllegalAccessException.html` |   |
| `https://developer.android.com/reference/java/lang/ClassNotFoundException.html` |   |