Save the date! Android Dev Summit is coming to Mountain View, CA on November 7-8, 2018.

AppComponentFactory

public class AppComponentFactory
extends Object

java.lang.Object
   ↳ android.app.AppComponentFactory


Interface used to control the instantiation of manifest elements.

Summary

Public constructors

AppComponentFactory()

Public methods

Activity instantiateActivity(ClassLoader cl, String className, Intent intent)

Allows application to override the creation of activities.

Application instantiateApplication(ClassLoader cl, String className)

Allows application to override the creation of the application object.

ContentProvider instantiateProvider(ClassLoader cl, String className)

Allows application to override the creation of providers.

BroadcastReceiver instantiateReceiver(ClassLoader cl, String className, Intent intent)

Allows application to override the creation of receivers.

Service instantiateService(ClassLoader cl, String className, Intent intent)

Allows application to override the creation of services.

Inherited methods

Public constructors

AppComponentFactory

added in API level 28
public AppComponentFactory ()

Public methods

instantiateActivity

added in API level 28
public Activity instantiateActivity (ClassLoader cl, 
                String className, 
                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
cl ClassLoader: The default classloader to use for instantiation.

This value must never be null.

className String: The class to be instantiated.

This value must never be null.

intent Intent: Intent creating the class.

This value may be null.

Returns
Activity

This value will never be null.

Throws
InstantiationException
IllegalAccessException
ClassNotFoundException

instantiateApplication

added in API level 28
public Application instantiateApplication (ClassLoader cl, 
                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
cl ClassLoader: The default classloader to use for instantiation.

This value must never be null.

className String: The class to be instantiated.

This value must never be null.

Returns
Application

This value will never be null.

Throws
InstantiationException
IllegalAccessException
ClassNotFoundException

instantiateProvider

added in API level 28
public ContentProvider instantiateProvider (ClassLoader cl, 
                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
cl ClassLoader: The default classloader to use for instantiation.

This value must never be null.

className String: The class to be instantiated.

This value must never be null.

Returns
ContentProvider

This value will never be null.

Throws
InstantiationException
IllegalAccessException
ClassNotFoundException

instantiateReceiver

added in API level 28
public BroadcastReceiver instantiateReceiver (ClassLoader cl, 
                String className, 
                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
cl ClassLoader: The default classloader to use for instantiation.

This value must never be null.

className String: The class to be instantiated.

This value must never be null.

intent Intent: Intent creating the class.

This value may be null.

Returns
BroadcastReceiver

This value will never be null.

Throws
InstantiationException
IllegalAccessException
ClassNotFoundException

instantiateService

added in API level 28
public Service instantiateService (ClassLoader cl, 
                String className, 
                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
cl ClassLoader: The default classloader to use for instantiation.

This value must never be null.

className String: The class to be instantiated.

This value must never be null.

intent Intent: Intent creating the class.

This value may be null.

Returns
Service

This value will never be null.

Throws
InstantiationException
IllegalAccessException
ClassNotFoundException