Integrating Requestly SDK

Installation

The best way to install the Requestly Android SDK is with a build system like Gradle. This ensures you can easily upgrade to the latest versions.
RQInterceptor is distributed through Maven Central. To use it you need to add the following Gradle dependency to your build.gradle file of you android app module (NOT the root file)
dependencies {
debugImplementation "io.requestly:requestly-android:2.1.0"
releaseImplementation "io.requestly:requestly-android-noop:2.1.0"
debugImplementation "io.requestly:requestly-android-okhttp:2.1.0"
releaseImplementation "io.requestly:requestly-android-okhttp-noop:2.1.0"
}

Initialization

Make sure to Create a new App to get the SDK key
Initialize the Requestly SDK in your Application class onCreate method.
Kotlin
Java
class App : Application(){
override fun onCreate() {
super.onCreate()
// Initialize Requestly SDK like this
Requestly.Builder(this, "<your-sdk-key>")
.build()
}
}
class App extends Application{
@Override
void onCreate() {
super.onCreate();
// Initialize Requestly SDK like this
new Requestly.Builder(this, "<your-sdk-key>")
.build();
}
}

Add Requestly Interceptor

To configure the Mobile Interceptor, you need to initialize the RQCollector and then add rqInterceptor as the last interceptor on okHttpClient

okHttp

Kotlin
Java
val collector = RQCollector(context=appContext)
โ€‹
val rqInterceptor = RQInterceptor.Builder(appContext)
.collector(collector)
.build()
val client = OkHttpClient.Builder()
.addInterceptor(rqInterceptor)
.build()
RQCollector collector = new RQCollector(context=appContext);
โ€‹
RQInterceptor rqInterceptor = new RQInterceptor.Builder(appContext)
.collector(collector)
.build();
โ€‹
OkHttpClient client = new OkHttpClient.Builder()
.addInterceptor(rqInterceptor)
.build();

Retrofit

Kotlin
Java
Retrofit.Builder()
.baseUrl(APIUtils.API_BASE_URI)
.client(okHttpClient) // okHttpClient with RQInterceptor
.build();
new Retrofit.Builder()
.baseUrl(APIUtils.API_BASE_URI)
.client(okHttpClient) // okHttpClient initialized above with RQInterceptor
.build();