本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}