Android SDK Documentation

The documentation describes the steps to integrate ActSDK into your Android Studio project.

Configure App

Configuring build.gradle
#1

Add ActSDK.aar to your application's build.gradle file

                  compile(name:'ActSDK', ext:'aar')
                
Preparing AndroidManifest.xml
#2

Add VPNService.java to your application's AndroidManifest.xml file

                  <service>
                      android:name="com.actmobile.actsdk.SDKVPNService"
                      android:permission="android.permission.BIND_VPN_SERVICE">
                      <intent-filter>
                          <action android:name="com.actmobile.actsdk.SDKVPNService" />
                      </intent-filter>
                  </service>
                

Make sure the necessary permissions are included

                  <uses-permission android:name="android.permission.INTERNET" />
                  <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
                

Using the SDK

Intializing the SDK
#1

Initialize the SDK like below:

                  ActSDK actSDK = ActSDK.getInstance();
                  actSDK.initSDKwithToken(getApplicationContext(), MainActivity.this, <INSERT SDK TOKEN>);
                
Note: Initialization requires passing of the application context, reference to main activity, and the provided SDK Token
Important Override
#2

The following override is necessary in your MainActivity. It is responsible for establishing the connection.

                  @Override
                  protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
                      if (requestCode == VPN_PREPARED && resultCode == RESULT_OK) {
                          actSDK.connectVPN();
                      }
                      super.onActivityResult(requestCode, resultCode, data);
                  }
                
Implementing the Interface
#3

Implementing the interface is required or else the SDK will throw an error. The following callback methods are for your use:

                  void vpnInitComplete();        // called when vpn init is complete and ready to connect
                  void onVPNConnected();         // called when vpn state is connected
                  void onVPNDisconnected();      // called when vpn state is disconnected
                  void onVPNConnecting();        // called when vpn state is connecting
                  void onVPNFailed();            // called when vpn failed
                  void onVPNRetrying();          // called when vpn is retrying
                

Available Methods

The following are the available methods for use. You may use them as per your requirements.

Connect VPN

                  actSDK.connectVPN()
                

Disconnect VPN

                  actSDK.disconnectVPN()
                

Return VPN Connected State

Returns true if connected. Returns false if disconnected
                  actSDK.isVpnConnected()
                

Get regions list

Returns String array of regions
                  actSDK.getRegions()
                

Get currently set region

Returns String value of currently selected region
                  actSDK.getCurrentRegion()
                

Get the default region

Returns the value of the default region set by the SDK
                  actSDK.getDefaultRegion()
                

Change Region for VPN

Accepts the new region name to set as VPN destination
                  actSDK.changeRegion(regionName)
                

Set the Admin port.

Accepts integer value for new port number
                  actSDK.setAdminPort(port)