Class SamLibrary

Object
SamLibrary

public class SamLibrary
extends Object
The CASIO Enterprise Developer Tools SAM Library

Since:
2.00
API Note:
The SAM Library is bound to the calling application on application startup time automatically.
The Library's lifecycle therefore depends on the application lifecycle.
Due to the Lifecycle of Android Applications and the underlying timing, it is strongly advised not to call any Library Methods inside the onCreate method.
When the activity is being launched (and hence the process gets created), the same applies to the onStart and onResume methods.
If you need to call any Library methods at application start in one of the above mentioned methods, you should use the Callback Mechanism offered by the onLibraryReady method instead.
For instance, instead of calling SamLibrary.openSam() directly in onCreate, use this code to postpone it to a Callback appropriately:
SamLibrary.onLibraryReady(new LibraryCallback() {
     public void onLibraryReady() {
         SamLibrary.openSam();
     }
 });

Which can be simplified to:
SamLibrary.onLibraryReady(() -> { SamLibrary.openSam(); });

Or even further to:
SamLibrary.onLibraryReady(SamLibrary::openSam);
  • Method Summary

    Modifier and Type Method Description
    static int closeSam()
    Close the SAM.
    static int communicateAPDU​(byte[] sendData, int sendLength, byte[] receiveData, int receiveLength)
    Communicate with SAM card in APDU format.
    static int communicateDirect​(byte command, byte[] sendData, int sendLength, byte[] receiveData, int receiveLength)
    Specify the command format and communicate directly with the SAM card.
    static int getTimeOutDelay()
    Get card timeout delay value
    static boolean isMethodSupported​(String methodName)
    Check whether the Method indicated by the String methodName parameter is supported on the currently active device
    static boolean isMethodSupported​(BigInteger method)
    Check whether the Method indicated by the BigInteger method parameter is supported on the currently active device
    static void onLibraryReady​(LibraryCallback callback)
    Add a new Callback to the Queue of Callbacks to be processed once the SAM Library Service becomes available
    static int openSam()
    Open the SAM.
    static int receiveATR​(byte[] receiveData)
    Get the ATR response data.
    static int sendPowerOff()
    Turn off the power of SAM card.
    static int sendPowerOn()
    Supply 5V power to the SAM card.
    static int setTimeOutDelay​(int delayMs)
    Set card timeout delay value in milliseconds