NEW Game developers: check out PacketZoom Mobile Connect
Important announcement: PacketZoom is now part of Roblox   

PZ Android Integraton Instructions

Android Native

If you want to use Maven

Please add the following to your build.gradle script

dependencies {
                            
//your other dependencies
compile('com.packetzoom:pz-android-sdk:3.+')
}

If you want to use .aar library

Step 1: Download the Android SDK.
Step 2: Put the downloaded .aar file into /libs folder.
Step 3: Add following lines in your build.gradle script
repositories {
flatDir {
dirs 'libs'
}
}

dependencies {
compile(name:'pz-android-sdk-3.2.9', ext:'aar')
}

Proguard Settings:

Please add the following to your proguard-rules-pro.txt or files that are included for proguard

-keep class com.packetzoom.speed.** { *; }
-keepclassmembers class com.packetzoom.** { *; }
-dontwarn com.packetzoom.**
### For OkHttp 2.x ###
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }
### For OkHttp 3.x ###
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
 

Finally: Add the following to your launcher activity OnCreate method:

PacketZoomClient.init(this, "<APP_ID>", "<API_KEY>");

If you are using the following HTTP Clients:

Picasso: specify the UrlConnectionDownloader when instantiating Picasso

mPicasso = new Picasso.Builder(this).downloader(new UrlConnectionDownloader(this)).build();

Optionally: if you are using OkHttpClient (OkHttpDownloader) with Picasso then please see the OkHttp instructions.

PacketZoom supports only versions later than 2.7.x of OkHttp. Please add following lines in your build.gradle script

OkHttp(2.7.x):
dependencies {
compile ('com.packetzoom:pz-okhttp-interceptor:3.2.+') {
transitive = true
}
}
OkHttp(3.x):
dependencies {
compile ('com.packetzoom:pz-okhttp3-interceptor:3.2.+') {
transitive = true
}
}
Please add PacketZoomInterceptor after intializing OkHttpClient.
If you have multiple interceptors, please add PacketZoomInterceptor as the last one in the chain.

OkHttp(2.7):

OkHttpClient client = new OkHttpClient();
client.interceptors().add(new PacketZoomInterceptor());

OkHttp(3.x):

OkHttpClient client = new OkHttpClient.Builder().addInterceptor(new PacketZoomInterceptor()).build();

Additionally:
In order to use the HTTP Optimizer service with OkHttp

new PZOptimizer().applyTo(client);

Retrofit: provide the UrlConnectionClient to have it work over HttpUrlConnection

UrlConnectionClient client = new UrlConnectionClient();
Retrofit retrofit = new Retrofit.Builder().baseUrl("https://api.github.com").client(client).build();

Optionally: if you are using OkHttpClient (OkClient) with Retrofit then please see the OkHttp instructions.

Volley, Glide and Fresco libraries already use HttpUrlConnection as the underlying HTTP stack and are automatically covered. Use them as-is.

If you are using the following HTTP Clients:

If you were extending WebViewClient in your code please replace it with PZWebViewClient
If you were also overriding public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) method please modify it to return super.shouldInterceptRequest(view, request) from places you were previously returning NULL.

Android Unity

Step 1: Download the Unity SDK.
Step 2: Import the .unitypackage package Assets->Import package->Custom package...
Step 3: In the first scene, insert this call:

PZAndroid.Init("<APP_ID>","<API_KEY>"); 

React Native (Android)

Step 1: First, download the library from npm:

npm install react-native-packetzoom@latest --save

Step 2: Then install the native dependencies: You can use rnpm (now part of react-native core) to add native dependencies automatically then continue the directions below depending on your target OS.

$ react-native link

React Native versions from 0.30 and above should work out of the box, we cannot guarantee that earlier than 0.30 will have smooth integration experience, it may require additional manual steps like rnpm for example.

import Packetzoom from 'react-native-packetzoom'
                                
Packetzoom.init("<APP_ID>", "<API_KEY>")

The XMLHttpRequest API is built in to React Native. This means that you can use third party libraries such as Frisbee, Fetch or Axios that depend on it. Ultimately XMLHttpRequest API is implemented using native NSURLSession API on iOS side and OkHttp3 on Android where PacketZoom native sdk would eventually intercept them.

From now on all your Fetch API, Axios or Apisauce requests will be accelerated by PacketZoom. You can access all NewRelic'sque kind of network analytics data on web dashboard when you login under your account.