NEW Game developers: check out PacketZoom Mobile Connect
Date By Leanid Vouk Tags Android / networking / http

PacketZoom Android now available!

We're excited to announce the public release of our Android SDK today. At PacketZoom we designed a modern, UDP-based network protocol with mobile apps in mind. This enables faster downloads, reduced latency, efficient and reliable data transfers between your app and the cloud. You can download the SDK here.

In addition to speed, one of the advantages of PacketZoom is that it handles seamless transition between networks without interrupting ongoing sessions. This is a unique advantage of the PacketZoom protocol over HTTP/TCP stack in common use today. You can learn more about the PacketZoom protocol and our cloud service here.

How did we get there ?

The PacketZoom SDK works by selectively capturing and proxying HTTP requests made by the native app that includes it. Our iOS SDK, released last year, accomplishes this by hooking into the Foundation URL Loading System via Apple approved API's.

When we started to work on our Android SDK it wasn't clear which path we should take and what API we should expose to app developers who might be using the many different HTTP clients available. We decided that we should try and hook into as low a layer as we could find. This would allow most higher level libraries (Volley, Retrofit etc.) to function with PacketZoom without modifications. It turns out that there are two HTTP clients available in the official Android SDK: HttpUrlConnection and AndroidHttpClient. Since Google deprecated the Apache-based AndroidHttpClient, we decided to focus on HttpUrlConnection for our first general release. Fortunately, Google provides hooks into that class for exactly this purpose.

With PacketZoom SDK installed in an Android app, whenever the app opens a URL via new URL.openConnection(), we can selectively proxy this URL via our UDP-based protocol. The "selectivity" comes from the filters set on our live dashboard.

You, the app developer, are still in control of your HTTP traffic from our live dashboard. You can designate which URLs to intercept by setting blacklist and whitelist regular expressions. This can be done anytime during the application's lifetime. All configuration changed via our dashboard is propagated to the client app at the start of a new app session.

The PacketZoom Fail-Forward technology also means our SDK doesn't start a proxy session until it obtains confirmation that PacketZoom service is live and performant in the geographic vicinity of the end-user. If something goes wrong with our servers, the application's requests will simply continue working with the original HTTP endpoints as if the PacketZoom SDK never existed.

pzplatform

How do I get started ?

The best part of using our SDK is its effortless drop-in integration. There is just a single line of code you need to add in order to start using PZ:

PacketZoomClient.init(this, "your app-id", "your api-key");

We recommed to call this method from your launcher Activity.OnCreate method. Don't forget to import com.packetzoom.speed.PacketZoomClient.

Gradle Configuration:

compile 'com.packetzoom:pz-android-sdk:3.+'

Packetzoom supports Android 4.0 and above with minSdkVersion="14"

Compatibility with other HTTP clients

Volley, Glide, Fresco

Since Volley, Glide, Fresco libraries are already using HttpUrlConnection as underlying HTTP stack you're automatically covered and can continue using them as-is.

Picasso

You need to specify UrlConnectionDownloader when instantiating Picasso:

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

OkHttp (2.7)

Packetzoom supports only 2.7.x version of OkHttp. Please add following lines in your build.gradle script:

dependencies {

    // your other dependencies
    // ....
    compile ('com.packetzoom:pz-android-sdk:3.1.+') {
        transitive = true
    }
 }

And don't forget to add PacketZoomInterceptor after intializing OkHttpClient

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

Retrofit

Similarly with Retrofit you need to provide UrlConnectionClient to make it work over HttpUrlConnection:

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

Unity

Yes we care about Unity devs and have Unity plugin with download link available shortly afer signup.

  • Step 1: Import the .unitypackage package Assets->Import package->Custom package...

  • Step 2: In the first scene call

   PZAndroid.init("your app id", "your api key"); 

Enjoy

We hope to reach every mobile user around the world and help reduce the daily frustrations caused by poor mobile networks. Do reach out to us via social channels or just email us at info@packetzoom.com if you'd like to learn more.


Share On:


Comments

comments powered by Disqus