Stay organized with collections Save and categorize content based on your preferences.

AppComponentFactory

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


Version of android.app.AppComponentFactory that works with androidx libraries. Note: This will only work on API 28+ and does not backport AppComponentFactory functionality.

Summary

Public constructors

Public methods

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

Allows application to override the creation of activities.

final @NonNull Application
@NonNull Application

Allows application to override the creation of the application object.

final @NonNull ContentProvider
@NonNull ContentProvider
instantiateProviderCompat(
    @NonNull ClassLoader cl,
    @NonNull String className
)

Allows application to override the creation of providers.

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

Allows application to override the creation of receivers.

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

Allows application to override the creation of services.

Public constructors

AppComponentFactory

public AppComponentFactory()

Public methods

instantiateActivity

public final @NonNull Activity instantiateActivity(
    @NonNull ClassLoader cl,
    @NonNull String className,
    @Nullable Intent intent
)
Throws
java.lang.InstantiationException java.lang.InstantiationException
java.lang.IllegalAccessException java.lang.IllegalAccessException
java.lang.ClassNotFoundException java.lang.ClassNotFoundException

instantiateActivityCompat

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
@NonNull ClassLoader cl

The default classloader to use for instantiation.

@NonNull String className

The class to be instantiated.

@Nullable Intent intent

Intent creating the class.

Throws
java.lang.InstantiationException java.lang.InstantiationException
java.lang.IllegalAccessException java.lang.IllegalAccessException
java.lang.ClassNotFoundException java.lang.ClassNotFoundException

instantiateApplication

public final @NonNull Application instantiateApplication(@NonNull ClassLoader cl, @NonNull String className)
Throws
java.lang.InstantiationException java.lang.InstantiationException
java.lang.IllegalAccessException java.lang.IllegalAccessException
java.lang.ClassNotFoundException java.lang.ClassNotFoundException

instantiateApplicationCompat

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
@NonNull ClassLoader cl

The default classloader to use for instantiation.

@NonNull String className

The class to be instantiated.

Throws
java.lang.InstantiationException java.lang.InstantiationException
java.lang.IllegalAccessException java.lang.IllegalAccessException
java.lang.ClassNotFoundException java.lang.ClassNotFoundException

instantiateProvider

public final @NonNull ContentProvider instantiateProvider(@NonNull ClassLoader cl, @NonNull String className)
Throws
java.lang.InstantiationException java.lang.InstantiationException
java.lang.IllegalAccessException java.lang.IllegalAccessException
java.lang.ClassNotFoundException java.lang.ClassNotFoundException

instantiateProviderCompat

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
@NonNull ClassLoader cl

The default classloader to use for instantiation.

@NonNull String className

The class to be instantiated.

Throws
java.lang.InstantiationException java.lang.InstantiationException
java.lang.IllegalAccessException java.lang.IllegalAccessException
java.lang.ClassNotFoundException java.lang.ClassNotFoundException

instantiateReceiver

public final @NonNull BroadcastReceiver instantiateReceiver(
    @NonNull ClassLoader cl,
    @NonNull String className,
    @Nullable Intent intent
)
Throws
java.lang.InstantiationException java.lang.InstantiationException
java.lang.IllegalAccessException java.lang.IllegalAccessException
java.lang.ClassNotFoundException java.lang.ClassNotFoundException

instantiateReceiverCompat

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
@NonNull ClassLoader cl

The default classloader to use for instantiation.

@NonNull String className

The class to be instantiated.

@Nullable Intent intent

Intent creating the class.

Throws
java.lang.InstantiationException java.lang.InstantiationException
java.lang.IllegalAccessException java.lang.IllegalAccessException
java.lang.ClassNotFoundException java.lang.ClassNotFoundException

instantiateService

public final @NonNull Service instantiateService(
    @NonNull ClassLoader cl,
    @NonNull String className,
    @Nullable Intent intent
)
Throws
java.lang.InstantiationException java.lang.InstantiationException
java.lang.IllegalAccessException java.lang.IllegalAccessException
java.lang.ClassNotFoundException java.lang.ClassNotFoundException

instantiateServiceCompat

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
@NonNull ClassLoader cl

The default classloader to use for instantiation.

@NonNull String className

The class to be instantiated.

@Nullable Intent intent

Intent creating the class.

Throws
java.lang.InstantiationException java.lang.InstantiationException
java.lang.IllegalAccessException java.lang.IllegalAccessException
java.lang.ClassNotFoundException java.lang.ClassNotFoundException