AppComponentFactory

Added in 1.1.0

@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

Added in 1.1.0
public AppComponentFactory()

Public methods

instantiateActivityCompat

Added in 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
@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.

instantiateApplicationCompat

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

The default classloader to use for instantiation.

@NonNull String className

The class to be instantiated.

instantiateProviderCompat

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

The default classloader to use for instantiation.

@NonNull String className

The class to be instantiated.

instantiateReceiverCompat

Added in 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
@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.

instantiateServiceCompat

Added in 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
@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.