Kits de Desenvolvimento de Software de scanner de Generalscan

Generalscan Kits de desenvolvimento SDK Introdução

GS-SDK1
Kits de desenvolvimento do SDK da Generalscan é um SDK kits desenvolvido pela Generalscan para que os desenvolvedores de software de terceiros usem a gama de scanners Bluetooth da Generalscan na plataforma de smartphones Android. O kit fornece várias funções básicas faz com que os utilizadores incorporem de forma simples e direta o scanner Bluetooth da Generalscan na aplicação deles sem entender protocolos Bluetooth complexos e mecanismos de comunicação de vários dispositivos USB.
O kit de desenvolvimento do SDK Generalscan fornece várias funções de software, incluindo comunicação Bluetooth SPP, emparelhamento, transferência de dados, modificação do nome do dispositivo Bluetooth, definições de função de código de barras, leitura de ID de hardware, algoritmo de encriptação DES e algoritmo de desencriptação, definição de tempo de sono de espera e outras funções
O código fonte Geralscan SDK é mantido no GitHub e os utilizadores podem descarregá-lo à vontade:  

图标库-01

Introduzir o SDK para projetos android Studio

  1. Copy the SDK aar file to app/libs
  2. Add the flatDir setting Gradle configuration to your Android project. In your root build.gradle file:
allprojects { 
repositories 
{
jcenter()
flatDir { dirs 'libs' }  // add flatDir setting
} 
}

  1. Open app level build.grdle file and add .aar file and kotlin runtime

    dependencies 
    { 
    implementation 'org.jetbrains.kotlin:kotlin-stdlib:1.3.10'     
    implementation(name:'generalscan-sdk-1.0', ext:'aar')
    }
  1. Add the follow permissions into manifest.xml

    <!-- Permission For Bluetooth -->
    <uses-permission android:name="android.permission.BLUETOOTH" /> 
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 
    <uses-permission android:name="android.permission.VIBRATE" /> 
    <!-- Permissions for USB Host (Scan Buddy) -->
    <uses-feature android:name="android.hardware.usb.host" android:required="true" />
    <!-- Show Alert Dialog in Service -->
    <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />

  1. Add the follow service declarations into manifest.xml
<service android:name="com.generalscan.scannersdk.core.session.bluetooth.
service.BluetoothConnectService"
android:enabled="true"    
android:exported="true" />
<service android:name="com.generalscan.scannersdk.core.session.usbhost.
service.UsbHostService"    
android:enabled="true" 
android:exported="true" /> 

<service android:name="com.generalscan.scannersdk.core.session.usbhost.
service.FloatingScanButtonService"       
android:enabled="true"    
android:exported="true" />


图标库-02

Interagir com um scanner Bluetooth

  1. Turn on Bluetooth
  2. Start Bluetooth session after activity created

    BluetoothConnectSession mBluetoothConnectSession = new BluetoothConnectSession(this);
    
    //Setup session listener
    
    mBluetoothConnectSession.setSessionListener( 
    new SessionListener()
    {
    //When session is ready
    @Override
    public void onSessionReady(IConnectSession iConnectSession) { 
    //TODO:to connect the device here or later
    } 
    //When session service initialization timeout
    @Override
    public void onSessionStartTimeOut(IConnectSession iConnectSession) {
    //TODO:show error message
    } 
    }
    ); 
    mBluetoothConnectSession.startSession();

图标库-03

Configurar o recetor para ler o código de barras

Setup listenter to ceceieve data

mBluetoothConnectSession.setConnectListener( 

new CommunicateListener() 

{  

//Bluetooth device disconnected

@Override

public void onDisconnected()

{ showMessage("Device has been disconnected"); 

}



     

//Bluetooth device connect failed

@Override

public void onConnectFailure(String errorMessage) {   

showMessage(errorMessage); 

}  



//Bluetooth device connect success

@Override

public void onConnected() {    

showMessage(R.string.scanner_connect_success); 

}  





//Scanner data received

@Override

public void onDataReceived(String data) { mTxtReceiveData.append(data); 

}  





//Bluetooth command callback

@Override

public void onCommandCallback(String name, String data) { mTxtReceiveData.append("$name:$data"); 

}  





//Battery data receive

@Override

public void onBatteryDataReceived(String voltage, String percentage) { mTxtReceiveData.append(voltage + ":" + percentage); 

}  





//Scanner command timeout

@Override

public void onCommandNoResponse(String errorMessage) { 

}  





//Data receive error

@Override

public void onRawDataReceiveError(String errorMessage, String source) { 

}  





//Raw data receive

@Override

public void onRawDataReceived(byte data) { 

}

}

 );


图标库-04

Emparelhar Bluetooth, coneção, sessão de paragem

Pair Bluetooth device
Connect Bluetooth device

BluetoothAdapter mBluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter()
BluetoothDevice device = BluetoothAdapter.getRemoteDevice(mSelectedDeviceAddress);
mBluetoothConnectSession.setBluetoothDeviceToConnect(device); mBluetoothConnectSession.connect();

Stop Bluetooth session after activity is destroy
//Send current bluetooth session
mBluetoothConnectSession.endSession();


















































 
 

Google mercado Download gratuito do software

 
GS-SDK1