As an example of integration, please use the sample app provided in our GitHub repository as a reference

 

Dependency


In Android Studio open Project Structure and choose to add a new Module, then 'Import .JAR/.AAR package' and navigate to your copy of icardpossdk.aar library.

Add the dependency to a module in your build.gradle:

compile project(':icardpossdk')

Add the following dependencies:

    compile 'com.android.support:appcompat-v7:25.0.1'
    compile 'com.android.support:design:25.0.1'
    compile 'com.android.support:support-v4:25.0.1'
    compile 'com.android.support:gridlayout-v7:25.0.1'
    compile 'com.android.support:cardview-v7:25.0.1'

 

Initialization


Initialize the MyPos components in your app:

public class SampleApplication extends Application {
	
private POSHandler  mPOSHandler;

@Override
public void onCreate() {
	super.onCreate();
	POSHandler.setCurrency(Currency.EUR);
 	mPOSHandler = POSHandler.getInstance();
}

Optional settting for default receipt configuration is avaibale:

POSHandler.setDefaultReceiptConfig(POSHandler.RECEIPT_PRINT_ONLY_MERCHANT_COPY);

If set the default receipt configuration can be removed:

POSHandler.clearDefaultReceiptConfig();

Optional setting for the language of the receipts is avaibale(default is Language.ENGLISH):

POSHandler.setLanguage(Language.GERMAN);

isTerminalBusy() returns boolean to check if an operation is being performed at the moment:

POSHandler.getInstance().isTerminalBusy();

 

Connect to terminal


Choose connection type:

POSHandler.setConnectionType(ConnectionType.BLUETOOTH);
POSHandler.getInstance().connectDevice(context);

If connection type is set to BLUETOOTH, make sure ACCESS_COARSE_LOCATION permission is given in order to discover available bluetooth devices.

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && ContextCompat.checkSelfPermission(this, 
	Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            requestPermissions(new String[]{Manifest.permission.ACCESS_COARSE_LOCATION}, PERMISSION_COARSE_LOCATION);
}

 

Attach connection listener


mPOSHandler.setConnectionListener(new ConnectionListener() {
    @Override
    public void onConnected(final BluetoothDevice device) {
        // handle connected event here
    }
});