Integration with Java native application
Our library is written in Kotlin, but it is fully compatible with an Android Java application. The integration with a Java application is the same as with a Kotlin written application.
Once the library is included as dependency in the gradle file, the library needs to be initialized with the context of the application.
Code Sample. initialize library in Java application
@Override
public void onCreate() {
super.onCreate();
AndroidPosIntegration.INSTANCE.init(this);
...
}
In the previous example, in the onCreate method of the class that is extending the Android Application class, the AndroidPosIntegration.init() method is called from the Java code. The INSTANCE part is needed as compatibility between Java and Kotlin library.
Once the application has been initialized, an instance of the PosIntegrationService can be got using the following code:
Code Sample. get PosIntegrationService instance from CM POS Payments AndroidPosIntegrationLibrary
PosIntegrationService paymentService = AndroidPosIntegration.INSTANCE.getInstance();