Class BLETransfer

  • All Implemented Interfaces:
    com.scytales.mvalid.sdk.engagement.DeviceEngagementDependent , com.scytales.mvalid.sdk.retrieval.Transfer , com.scytales.mvalid.sdk.retrieval.TransferProgressListenable , com.scytales.mvalid.sdk.retrieval.TransferReceiveDependent , java.io.Closeable , java.lang.AutoCloseable

    
    public final class BLETransfer
     implements Transfer<D>, DeviceEngagementDependent, TransferReceiveDependent, TransferProgressListenable, Closeable
                        

    Transfer implementation that transfers data using Bluetooth LE.

    For android SDK >= 31

    • android.Manifest.permission.BLUETOOTH_ADVERTISE
    • android.Manifest.permission.BLUETOOTH_SCAN
    • android.Manifest.permission.BLUETOOTH_CONNECT

    For android SDK <31

    • android.Manifest.permission.ACCESS_FINE_LOCATION
    • android.Manifest.permission.ACCESS_COARSE_LOCATION
        public class SomeActivity extends 
    androidx.appcompat.app.AppCompatActivity
    implements DeviceEngagementCallback, TransferReceiveCallback, TransferProgressListener { private static final String TAG = "SomeActivity"; private Map<String, Map<String, Map<String, Boolean>>> docRequests = ... private SessionManager sessionManager; @Override public void onEngage(@NonNull Received<EngagementReceived> engagementReceived) { engagementReceived.run( failure -> { android.util.Log.e(TAG, failure.toString()); }, success -> { DeviceEngagement deviceEngagement = success.getDeviceEngagement(); Handover handover = success.getHandover(); try { sessionManager = new SessionManager(deviceEngagement, handover); byte[] requestBytes = sessionManager.createRequest(docRequests); BLETransfer bleTransfer = new BLETransfer(getApplicationContext()); bleTransfer.setProgressListener(this); bleTransfer.setTransferReceiveCallback(this); bleTransfer.forDeviceEngagement(deviceEngagement); bleTransfer.send(requestBytes); } catch (SDKException e) { android.util.Log.e(TAG, e.getMessage(), e); } }); } @Override public void onProgressEvent(@NonNull TransferProgressEvent event) { android.util.Log.i(TAG, event.toString()); } @Override public void onReceive(@NonNull Received<TransferReceived> transferReceived) { transferReceived.run( failure -> { android.util.Log.e(TAG, failure.toString()); }, success -> { success.runForDevice(receivedBytes -> { try { com.scytales.mvalid.sdk.session.SessionData sessionData = sessionManager.decryptResponse(receivedBytes); // do stuff with decrypted } catch (SDKException e) { // handle decryption error } }); }); } }