Developers SDK

VPN Unlimited SDK v1.6 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 {
  implementation 'com.keepsolid.androidkeepsolidcommon:VpnUnlimitedSDK@aar'
}

for the correct work of SDK, you must also add the following dependencies:

  implementation 'com.madgag.spongycastle:bcpkix-jdk15on:1.58.0.0'
  implementation 'com.madgag.spongycastle:bcpg-jdk15on:1.58.0.0'
  api 'com.google.code.gson:gson:2.10.1'
  api 'com.squareup.okhttp3:okhttp:3.14.9' 
  api 'org.conscrypt:conscrypt-android:2.2.1'

After setup is done you should be able to use all the classes from SDK by including it with import com.keepsolid.androidkeepsolidcommon.*; 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.

Initializing SDK

Use the following setup code in your Application class onCreate() method to initialize VPN Unlimite SDK using your App ID and App Secret:

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

To ensure the correct display of the dialogs from the VPN Unlimited SDK and the normal operation of the listeners to the VPN connection status, please follow the next steps:

  • In your project, create a class that extends KSDefaultDialogActivity and specify it in the Manifest file as Activity with Intent-Filter set to Action: your.application.package.name.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="your.application.package.name.DialogActivity.LAUNCH_INTENT_ACTION" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
    </activity>
            

    Note that you need to replace your.application.package.name with the real package name of your application.

  • Add the special receiver configured as shown below to the Manifest file. In this case, you also need to replace your.application.package.name with the real package name of your application.

    <receiver
        android:name="com.keepsolid.androidkeepsolidcommon.vpnunlimitedsdk.vpn.controllers.VPNUStateController"
        android:label="VPNUStateController">
        <intent-filter>
            <action android:name="your.application.package.name.OpenVpnService.OPEN_VPN_STATE_BROADCAST_ACTION" />
            <action android:name="your.application.package.name.OpenVpnService.ENABLE_VPN_CONNECTION_BROADCAST_ACTION" />
            <action android:name="your.application.package.name.OpenVpnService.DISABLE_VPN_CONNECTION_BROADCAST_ACTION" />
            <action android:name="your.application.package.name.OpenVpnService.CHECK_SERVICE_CONNECTION_BROADCAST_ACTION" />
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>            
            
  • To support Android 13+ (api33+) you need to add new permissions to manifest file

    <uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>>
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE"/>>        
            

    also you need to request notification permission in proper way.

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
  • VPNUProtoConfig
  • VPNUDefaultLocalizedResponseProvider
  • VPNUException
  • VPNUFacade
  • VPNUImageLoader
  • VPNUImageRequest
  • VPNUImageResponse
  • VPNULocationCoordinate2D
  • 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
  • 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();
VPNU Android SDK getting started PDF
Other versions: 1.0 / 1.1 / 1.2 / 1.3 / 1.4 / 1.5