Skip to content
Mike Hardy edited this page Mar 26, 2019 · 6 revisions

Implementing an extension

Create a class extending one of the supported interfaces.

It has to be public and have a zero-argument public constructor (as a result, it cannot be an inner class).

E.g.

public MyAdmin implements ReportingAdministrator {
    public MyAdmin() {
        Log.d("MyAdmin", "MyAdmin was loaded");
    }
}

Supported Extensions are Collector, ReportInteraction, ReportingAdministrator, ReportSenderFactory and ConfigurationBuilderFactory.

Registering an extension

Choose one of the following alternatives:

By annotation

Add the following dependencies to your build.gradle:

compileOnly "com.google.auto.service:auto-service-annotations:1.0-rc5"
annotationProcessor "com.google.auto.service:auto-service-annotations:1.0-rc5"

Then annotate your extension with the following:

@AutoService(Extension.class)

E.g.

@AutoService(ReportingAdministrator.class)
public MyAdmin implements ReportingAdministrator {

By file

See ServiceLoader for manual provider registration

Clone this wiki locally