Android SDK Integration Guide
To help you integrate the myPOS Android SDK into your mobile application, follow the steps below. You can also refer to our sample app on GitHub for a complete working example.
Installation
Add the Maven repository to your build.gradle:
allprojects {
repositories {
mavenCentral()
}
}
Add the SDK dependency to your app module:
implementation 'com.mypos:slavesdk:2.1.6'
Initialization
Initialize the myPOS components in your application class:
public class SampleApplication extends Application {
private POSHandler mPOSHandler;
@Override
public void onCreate() {
super.onCreate();
POSHandler.setCurrency(Currency.EUR);
mPOSHandler = POSHandler.getInstance();
}
Optional Settings
Receipt Configuration
Set the default receipt behavior:
POSHandler.setDefaultReceiptConfig(POSHandler.RECEIPT_PRINT_ONLY_MERCHANT_COPY);
To remove the default config:
POSHandler.clearDefaultReceiptConfig();
Language Setting
Set the receipt language (default is English):
POSHandler.setLanguage(Language.GERMAN);
Check Terminal Activity
Check if the terminal is busy:
POSHandler.getInstance().isTerminalBusy();
Connect to Terminal
Select connection type:
POSHandler.setConnectionType(ConnectionType.BLUETOOTH);
POSHandler.getInstance().connectDevice(context);
Check permissions:
if (POSHandler.getInstance().checkPermissions(context)) {
// continue...
} else {
// permissions request is sent...
}
Handle permission results:
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
if (requestCode == POSHandler.PERMISSIONS_REQUEST_CODE) {
// check permissions result...
}
}
Bluetooth Low Energy (Go 2 Terminals)
To skip manual pairing, use a BroadcastReceiver:
IntentFilter intentFilter = new IntentFilter(BluetoothDevice.ACTION_PAIRING_REQUEST);
intentFilter.setPriority(IntentFilter.SYSTEM_HIGH_PRIORITY);
registerReceiver(broadCastReceiver, intentFilter);
private BroadcastReceiver broadCastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if(BluetoothDevice.ACTION_PAIRING_REQUEST.equals(action))
{
BluetoothDevice bluetoothDevice = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
int blPin = intent.getIntExtra("android.bluetooth.device.extra.PAIRING_KEY", 123456);
bluetoothDevice.setPin(blPin);
bluetoothDevice.createBond();
}
}
};
Attach Listeners
Connection Listener
mPOSHandler.setConnectionListener(new ConnectionListener() {
@Override
public void onConnected(final BluetoothDevice device) {
// handle connected event here
}
});
POS Ready Listener
mPOSHandler.setPOSReadyListener(new POSReadyListener() {
@Override
public void onPOSReady() {
// now you can start a transaction
}
});
Send E-Receipt
To send an email or SMS receipt, use the following configuration and listener:
POSHandler.getInstance().setPOSCredentialsListener(new POSCredentialsListener() {
@Override
public void askForCredentials(final CredentialsListener listener) {
listener.onCredentialsSet("email@example.com"); // instead of email you can pass a phone number
}
});
Pro Tip: Always monitor connection and terminal readiness before initiating transactions, and wrap all listener logic with proper error handling for a smoother user experience.