Developers SDK

VPN Unlimited SDK v1.3 for Android

Getting started

Overview

VPN Unlimited SDK for Android is shipped as a distribution of an Android Library Project. It is written in Java and C++ and is available for Android 4.0 and later.

Setup

Drag and drop VpnUnlimitedSDK.aar into your project libs folder.

In order to use it you have to add following lines of code to yours build.gradle

dependencies {
    compile(name:'VpnUnlimitedSDK', ext:'aar')
}

After setup is done you should be able to use all the classes from SDK by including it with import keepsolid.com.androidvpnunlimitedsdk.*; directive.

Note:

Current version of VPN Unlimited SDK uses the following libraries under the hood:

  • libcurl
  • libopenssl
  • libcares
  • libcrypto
  • xopenssl

If your project uses one of these libraries and you get conflicts please contact VPN Unlimited team for further investigation.

Using App ID and App secret

Use the following setup code in your Application class onCreate() method:

VPNUFacade.getInstance().prepare(getApplicationContext(),
    Constants.APPLICATION_ID, Constants.APPLICATION_SECRET);

In order to properly display VPN Unlimited SDK dialogs you also need to create class that extends KSDefaultDialogActivity and declare it in Manifest as activity with Intent filter for action keepsolid.com.androidvpnunlimitedsdk.dialogs.DialogActivity.LAUNCH_INTENT_ACTION:

public class BaseDialogActivity extends KSDefaultDialogActivity {

    @Override
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
    }
}
<activity
    android:name=".BaseDialogActivity"
    android:excludeFromRecents="true">
        <intent-filter>
            <action android:name="keepsolid.com.androidvpnunlimitedsdk.dialogs.DialogActivity.LAUNCH_INTENT_ACTION" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
</activity>
Classes

This SDK is designed in classical OOP style. We don't provide one single interface, but rather a handful of interfaces which you can use in any desired combination. All network calls are synchronous, so you should never call them from main thread. This limitation is highlighted by the fact, that you actually can perform several steps in a row serially on secondary thread and come back to main thread with a desired result.

Here is the complete list of classes:

  • LocalizedResponseProvider
  • OpenVpnStatus
  • OpenVpnStatusChangedListener
  • VPNUAccountDevice
  • VPNUAccountDeviceStatistic
  • VPNUAccountManager
  • VPNUAccountStatus
  • VPNUAccountUserInfo
  • VPNUAuthDelegate
  • VPNUAuthDelegate.Response
  • VPNUAuthorizer
  • VPNUConfigurator
  • VPNUDefaultLocalizedResponseProvider
  • VPNUException
  • VPNUFacade
  • VPNUImageLoader
  • VPNUImageRequest
  • VPNUImageResponse
  • VPNULocationCoordinate2D
  • VPNUProxyConfiguration
  • VPNUProxyManager
  • VPNUPurchaseItem
  • VPNUPurchaseManager
  • VPNURequest
  • VPNURequestBuilder
  • VPNUResponse
  • VPNUServer
  • VPNUServersManager
  • VPNUTransport

You can see the complete documentation for each class at Reference page.

Here we just briefly describe the standard workflow.

VPNUFacade

The VPNUFacade is to some degree the main class in SDK. It provides interfaces to all SDK APIs, namely:

  • VPNUAuthorizer
  • VPNUAccountManager
  • VPNUPurchaseManager
  • VPNUServersManager
  • VPNUTransport
  • VPNUProxyManager
  • LocalizedResponseProvider
  • VPNUImageLoader
  • VPNUConfigurator
  • VPNURequestBuilder
Multithreading

As stated previously, all network calls in this SDK are performed synchronously. That means that you should perform them all on a non-main thread, otherwise it would block it and never come back. Every method which falls into this category is explicitly documented.

FAQ

In every example in the FAQ section it is implicitly considered that SDK is set up properly before any calls:

VPNUFacade.getInstance().prepare(getApplicationContext(),
    Constants.APPLICATION_ID, Constants.APPLICATION_SECRET);

It is also considered that the code is executing on a secondary thread, for example:

new Thread(new Runnable() {
    @Override
    public void run() {
        //SDK calls
    }
}).start();
Other versions: 1.0 / 1.1 / 1.2 / 1.4 / 1.5