Exemple #1
0
    public void SetConnectionCallbackListener(
        Action <string> OnConnected
        , Action <string> OnConnecting
        , Action <string> OnNotConnected
        , Action <string> OnConnectionFailed
        , Action <string> OnConnectionLost
        , Action <string> OnConnectToDevice
        )
    {
                #if UNITY_ANDROID
        if (Application.platform == RuntimePlatform.Android)
        {
            BluetoothConnectionCallback bluetoothConnectionCallback = new BluetoothConnectionCallback();
            bluetoothConnectionCallback.onConnected        = OnConnected;
            bluetoothConnectionCallback.onConnecting       = OnConnecting;
            bluetoothConnectionCallback.onNotConnected     = OnNotConnected;
            bluetoothConnectionCallback.onConnectionFailed = OnConnectionFailed;
            bluetoothConnectionCallback.onConnectionLost   = OnConnectionLost;
            bluetoothConnectionCallback.onConnectToDevice  = OnConnectToDevice;

            jo.CallStatic("setConnectionCallbackListener", bluetoothConnectionCallback);
            AUP.Utils.Message(TAG, "setDataCallbackListener");
        }
        else
        {
            AUP.Utils.Message(TAG, "warning: must run in actual android device");
        }
                #endif
    }
    public void SetConnectionCallbackListener( 
	            Action <string>OnConnected
	            ,Action <string>OnConnecting
	            ,Action <string>OnNotConnected
	            ,Action <string>OnConnectionFailed
	            ,Action <string>OnConnectionLost
	            ,Action <string>OnConnectToDevice
	     )
    {
        #if UNITY_ANDROID
        if(Application.platform == RuntimePlatform.Android){
            BluetoothConnectionCallback bluetoothConnectionCallback = new BluetoothConnectionCallback();
            bluetoothConnectionCallback.onConnected = OnConnected;
            bluetoothConnectionCallback.onConnecting = OnConnecting;
            bluetoothConnectionCallback.onNotConnected = OnNotConnected;
            bluetoothConnectionCallback.onConnectionFailed = OnConnectionFailed;
            bluetoothConnectionCallback.onConnectionLost = OnConnectionLost;
            bluetoothConnectionCallback.onConnectToDevice = OnConnectToDevice;

            jo.CallStatic("setConnectionCallbackListener",bluetoothConnectionCallback);
            Utils.Message(TAG,"setDataCallbackListener");
        }else{
            Utils.Message(TAG,"warning: must run in actual android device");
        }
        #endif
    }