当前位置: 首页>>代码示例>>Java>>正文


Java BluetoothDevice.createRfcommSocketToServiceRecord方法代码示例

本文整理汇总了Java中android.bluetooth.BluetoothDevice.createRfcommSocketToServiceRecord方法的典型用法代码示例。如果您正苦于以下问题:Java BluetoothDevice.createRfcommSocketToServiceRecord方法的具体用法?Java BluetoothDevice.createRfcommSocketToServiceRecord怎么用?Java BluetoothDevice.createRfcommSocketToServiceRecord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.bluetooth.BluetoothDevice的用法示例。


在下文中一共展示了BluetoothDevice.createRfcommSocketToServiceRecord方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ConnectThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public ConnectThread(BluetoothDevice device, boolean secure)
{
    mmDevice = device;
    BluetoothSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Get a BluetoothSocket for a connection with the given BluetoothDevice
    try
    {
        if (secure)
        {
            tmp = device.createRfcommSocketToServiceRecord(MY_UUID_SECURE);
        }
        else
        {
            tmp = device.createInsecureRfcommSocketToServiceRecord(MY_UUID_INSECURE);
        }
    }
    catch (IOException e)
    {
        MyLog.e(TAG, "Socket Type: " + mSocketType + " create() failed", e);
    }

    mmSocket = tmp;
}
 
开发者ID:Mozta,项目名称:ELM327,代码行数:26,代码来源:BluetoothIOGateway.java

示例2: ConnectThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public ConnectThread(BluetoothDevice device, boolean secure) {
    mmDevice = device;
    BluetoothSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Get a BluetoothSocket for a connection with the
    // given BluetoothDevice
    try {
        if (secure) {
            tmp = device.createRfcommSocketToServiceRecord(
                    MY_UUID_SECURE);
        } else {
            tmp = device.createInsecureRfcommSocketToServiceRecord(
                    MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "create() failed", e);
    }
    mmSocket = tmp;
    mState = STATE_CONNECTING;
}
 
开发者ID:AviralGarg1993,项目名称:VR-One,代码行数:22,代码来源:BluetoothListener.java

示例3: ConnectThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public ConnectThread(BluetoothDevice device, boolean secure) {
    mmDevice = device;
    BluetoothSocket tmp = null;
    mSocketType = secure ? "Secure" : "Insecure";

    // Get a BluetoothSocket for a connection with the
    // given BluetoothDevice
    try {
        if (secure) {
            tmp = device.createRfcommSocketToServiceRecord(
                    MY_UUID_SECURE);
        } else {
            tmp = device.createInsecureRfcommSocketToServiceRecord(
                    MY_UUID_INSECURE);
        }
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: " + mSocketType + "create() failed", e);
    }
    mmSocket = tmp;
}
 
开发者ID:tkmarsh,项目名称:SmartRC,代码行数:21,代码来源:BluetoothChatService.java

示例4: ConnectThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public ConnectThread(BluetoothAdapter btAdapter, BluetoothDevice device, MessageProto.Message message, CommunicationListener listener) {
    this.btAdapter = btAdapter;
    this.message = message;
    this.listener = listener;

    try {
        // Get a BluetoothSocket to connect with the given BluetoothDevice.
        // MY_UUID is the app's UUID string, also used in the server code.
        if(mmSocket == null || mmSocket.getRemoteDevice() == null ||
                !mmSocket.getRemoteDevice().getAddress().equals(device.getAddress())) {
            mmSocket = device.createRfcommSocketToServiceRecord(AcceptThread.myUUID);
            alreadyConnected = false;
        } else {
            alreadyConnected = true;
        }

    } catch (IOException e) {
        Log.e(TAG, "Socket's create() method failed", e);
    }
}
 
开发者ID:wkmeijer,项目名称:CS4160-trustchain-android,代码行数:21,代码来源:ConnectThread.java

示例5: ConnectThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public ConnectThread(BluetoothDevice device) {
    // Use a temporary object that is later assigned to mmSocket,
    // because mmSocket is final
    BluetoothSocket tmp = null;
    mmDevice = device;

    // Get a BluetoothSocket to connect with the given BluetoothDevice
    try {
        // MY_UUID is the app's UUID string, also used by the server code
        UUID uuid = Constants.myUUID;
        tmp = device.createRfcommSocketToServiceRecord(uuid);
    } catch (IOException e) {
        Log.e(Constants.TAG, "Create RFcomm socket failed", e);
    }
    mmSocket = tmp;
}
 
开发者ID:bilal-rashid,项目名称:Lazy-Switches,代码行数:17,代码来源:BluetoothService.java

示例6: ClientThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public ClientThread(BluetoothDevice device, Handler handler, boolean secure) {
    BluetoothSocket tempSocket = null;
    this.handler = handler;
    this.secure = secure;
    this.device = device;

    try {
        if (secure)
            tempSocket = device.createRfcommSocketToServiceRecord(UUID.fromString(Constants.UUID_STRING));
        else
            tempSocket = device.createInsecureRfcommSocketToServiceRecord(UUID.fromString(Constants.UUID_STRING));

    } catch (Exception e) {
        Log.e(TAG, e.toString());
    }
    this.socket = tempSocket;
}
 
开发者ID:n8fr8,项目名称:LittleBitLouder,代码行数:18,代码来源:ClientThread.java

示例7: ConnectBluetoothThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public ConnectBluetoothThread(BluetoothDevice device, BluetoothAdapter mBluetoothAdapter, Handler handler) {
    // Use a temporary object that is later assigned to mmSocket,
    // because mmSocket is final
    this.mBluetoothAdapter=mBluetoothAdapter;
    this.handler=handler;
    mmDevice = device;

    BluetoothSocket tmp = null;
    msg=new Message();

    // Get a BluetoothSocket to connect with the given BluetoothDevice
    try {
        // MY_UUID is the app's UUID string, also used by the server code
        String uuid="00001101-0000-1000-8000-00805f9b34fb";
        tmp = device.createRfcommSocketToServiceRecord(UUID.fromString(uuid));
    } catch (IOException e) {
        Log.d(TAG, "ConnectBluetoothThread: 初始化uuid错误");
    }
    mmSocket = tmp;
}
 
开发者ID:Axe-Ishmael,项目名称:Blockly,代码行数:21,代码来源:ConnectBluetoothThread.java

示例8: ConnectThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public ConnectThread(BluetoothDevice device) {
    mmDevice = device;
    BluetoothSocket tmp = null;

    // Get a BluetoothSocket for a connection with the
    // given BluetoothDevice
    try {
        tmp = device.createRfcommSocketToServiceRecord(SERIAL_PORT_CLASS);
    } catch (IOException e) {
        Log.e(TAG, "Socket Type: create() failed", e);
    }
    mmSocket = tmp;
    mState = STATE_CONNECTING;
}
 
开发者ID:haraldh,项目名称:iconsole-android,代码行数:15,代码来源:BluetoothChatService.java

示例9: ConnectThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public ConnectThread(BluetoothDevice device) {
    mmDevice = device;
    BluetoothSocket tmp = null;

    // Get a BluetoothSocket for a connection with the
    // given BluetoothDevice
    try {
        if(BluetoothService.this.isAndroid)
            tmp = device.createRfcommSocketToServiceRecord(UUID_ANDROID_DEVICE);
        else
            tmp = device.createRfcommSocketToServiceRecord(UUID_OTHER_DEVICE);
    } catch (IOException e) { }
    mmSocket = tmp;
}
 
开发者ID:voroshkov,项目名称:Chorus-RF-Laptimer,代码行数:15,代码来源:BluetoothService.java

示例10: ConnectThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public ConnectThread(BluetoothDevice device, BluetoothAdapter bluetoothAdapter, Handler handler) {
        mBluetoothAdapter=bluetoothAdapter;
        BluetoothSocket tmp = null;
        mDevice = device;
        mHandler=handler;
        try {
            //创建RFCOMM通道
            tmp = device.createRfcommSocketToServiceRecord(UUID.fromString(UUID_STR));
        } catch (IOException e) {
//            Log.d(TAG, "createRfcommSocketToServiceRecord error!");
        }

        mSocket = tmp;
    }
 
开发者ID:fergus825,项目名称:SmartOrnament,代码行数:15,代码来源:ConnectThread.java

示例11: createBluetoothSocket

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
private BluetoothSocket createBluetoothSocket(BluetoothDevice device) throws IOException {
    try {
        final Method m = device.getClass().getMethod("createInsecureRfcommSocketToServiceRecord", UUID.class);
        return (BluetoothSocket) m.invoke(device, BTMODULEUUID);
    } catch (Exception e) {
        Log.e("RecordVitalSignActivity", "Could not create Insecure RFComm Connection",e);
    }
    return  device.createRfcommSocketToServiceRecord(BTMODULEUUID);
}
 
开发者ID:pooi,项目名称:Nearby,代码行数:10,代码来源:RecordVitalSignActivity.java

示例12: ConnectThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public ConnectThread(BluetoothDevice device, UUID uuidToTry) {
    mmDevice = device;
    BluetoothSocket tmp = null;
    tempUuid = uuidToTry;

    // Get a BluetoothSocket for a connection with the
    // given BluetoothDevice
    try {
        tmp = device.createRfcommSocketToServiceRecord(uuidToTry);        	
    } catch (IOException e) {
        Log.e(TAG, "create() failed", e);
    }
    mmSocket = tmp;
}
 
开发者ID:sdrausty,项目名称:buildAPKsApps,代码行数:15,代码来源:BluetoothChatService.java

示例13: ConnectThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public ConnectThread(BluetoothDevice device, BluetoothAdapter mBluetoothAdapter, ConnectInterface connectInterface) {
    this.mBluetoothAdapter = mBluetoothAdapter;
    this.connectInterface = connectInterface;
    BluetoothSocket tmp = null;
    mmDevice = device;

    try {
        tmp = device.createRfcommSocketToServiceRecord(Utility.uuid);
    } catch (IOException e) {
        e.printStackTrace();
    }
    mmSocket = tmp;
}
 
开发者ID:wuhighway,项目名称:DailyStudy,代码行数:14,代码来源:ConnectThread.java

示例14: ClientThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public ClientThread(BluetoothAdapter bluetoothAdapter, BluetoothDevice device,
                    Handler handler) {
    this.bluetoothAdapter = bluetoothAdapter;
    this.device = device;
    this.uiHandler = handler;
    BluetoothSocket tmp = null;
    try {
        tmp = device.createRfcommSocketToServiceRecord(UUID.fromString(Params.UUID));
    } catch (IOException e) {
        e.printStackTrace();
    }
    socket = tmp;
}
 
开发者ID:QiaoJim,项目名称:BluetoothStudy,代码行数:14,代码来源:ClientThread.java

示例15: ConnectThread

import android.bluetooth.BluetoothDevice; //导入方法依赖的package包/类
public ConnectThread(BluetoothDevice device) {
    mmDevice = device;
    BluetoothSocket tmp = null;
    // 得到一个bluetoothsocket
    try {
        mmSocket = device.createRfcommSocketToServiceRecord
                (SERVICE_UUID);
    } catch (IOException e) {
        Log.e(TAG, "create() failed", e);
        mmSocket = null;
    }
}
 
开发者ID:BittleDragon,项目名称:BluetoothChatDemo,代码行数:13,代码来源:BluetoothChatUtil.java


注:本文中的android.bluetooth.BluetoothDevice.createRfcommSocketToServiceRecord方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。