TokenUSDK

Introduction

TokenUSDK is an Android SDK designed to provide users with access to multiple libraries through a unified interface. This documentation will guide you through the steps to integrate TokenUSDK into your Android project using a dedicated plugin to manage repository access credentials.

Integration Guide

Step 1: Applying Tokeninc Gradle Build Tool Plugin

This plugin allows you to configure your Android projects to consume artifacts from private repositories.

These credentials are asked by the plugin in a Java GUI and this procedure only has to be done once unless credentials are not changed.

If the repository dependencies are managed in project level build.gradle file, enable the build plugin as follows:

Using the plugins DSL, in newer versions of gradle

Project level build.gradle

plugins {
  id "com.tokeninc.tools.build" version "0.2"
}

Using legacy plugin application, in older versions of gradle

Project level build.gradle

buildscript {
  repositories {
    gradlePluginPortal()
  }
  dependencies {
    classpath "com.tokeninc.tools:tokeninc-gradle-plugin:0.2"
  }
}

apply plugin: "com.tokeninc.tools.build"

Applying Settings Plugin

If the repository dependencies are managed in project level settings.gradle file, enable the build plugin as follows:

Using the plugins DSL, in newer versions of gradle

Project level settings.gradle

plugins {
  id "com.tokeninc.tools.settings" version "0.2"
}

dependencyResolutionManagement {
  repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
  repositories {
    // ..
  }
}

Java GUI for Settings Plugin, Preferred on Android Studio IDE

On first sync, you will be prompted a window to enter repository consumer credentials:

You need to provide the following 3 properties to consume from a Maven Repository

  • consume-repo-url-1

  • consume-repo-usr-1

  • consume-repo-pwd-1

Step 2: Adding the Dependency

After applying plugin, you should be able to add TokenUSDK dependency as follow:

dependencies {
    implementation 'com.tokeninc:TokenUSDK:1.0.0'
}

Usage

TokenUSDK is initialized and accessed through the singleton class TokenUSDKManager. Once TokenUSDKManager is initialized, it can be used anywhere within your project. However, there are important considerations to ensure proper usage and avoid common pitfalls.

Initialization

The initialization and destroy process should be performed in the onCreate and onDestroy method of the Launcher activity. Same activity context should ne used for bot methods!

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TokenUSDKManager.getInstance().initUSDK(getBaseContext(), new ITokenUSDKCallback() {
            @Override
            public void onServicesConnected() {
                Log.i(TAG,"TokenUSDK -> onServiceConnected");
                binding.progressCircular.setVisibility(View.GONE);
            }

            @Override
            public void onServiceDisconnected() {
                Log.i(TAG,"TokenUSDK -> onServiceDisconnected");
                binding.progressCircular.setVisibility(View.VISIBLE);
            }
        });
    }
    
    @Override
    protected void onDestroy() {
        TokenUSDKManager.onDestroyUSDK(getBaseContext());
        super.onDestroy();
    }

Once initialized, the TokenUSDKManager class allows access to any service connection from anywhere in the application.

// example usage of KMSService usage
TokenUSDKManager.getInstance().getKMSService()

Functions

  • public PrinterServiceWrapper getPrinterService() : Returns 'PrinterServiceWrapper' for printer functionalities. For further information about Printer Service APIs, please visit: Printer Service

  • public RKLServiceWrapper getRKLService() : Returns 'RKLServiceWrapper 'for RKL service functionalities. For further information about RKL service APIs, please visit: RKL CA service

  • public DeviceInfoWrapper getDeviceInfo() : Returns 'DeviceInfoWrapper 'for DeviceInfo service functionalities. For further information about DeviceInfo service APIs, please visit: Device Library

  • public KMSWrapper getKMSService(): Returns 'KMSWrapper' for KMS service functionalities. For further information about KMS service APIs, please visit: KMS Library

  • public CardServiceWrapper getCardService() : Returns 'CardServiceWrapper' for Card Service functionalities. For further information about Card Service APIs, please visit: Card Service

Known Issues

Java GUI does not appear on first sync

When you apply and sync the project for the first time, you may not see a Java GUI popping up.

You might instead come across a warning message from the plugin that says: "Cannot instantiate credentials panel, current graphics environment does not support it!"

This is because the previous gradle daemon instance was started in a headless environment, and it must be stopped.

Start a terminal on the root directory of the project (e.g. by clicking the tab called Terminal located in the bottom left of Android Studio IDE) and stop the running gradle daemon(s):

./gradlew --stop

Last updated