Java Code Examples for android.bluetooth.BluetoothDevice#createInsecureRfcommSocketToServiceRecord()
The following examples show how to use
android.bluetooth.BluetoothDevice#createInsecureRfcommSocketToServiceRecord() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BluetoothChatService.java From connectivity-samples with Apache License 2.0 | 6 votes |
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; }
Example 2
Source File: CustomProcess.java From Smart-Glass with Apache License 2.0 | 6 votes |
@Override protected Void doInBackground(Void... devices) //while the progress dialog is shown, the connection is done in background { try { if (btSocket == null || !isBtConnected) { myBluetooth = BluetoothAdapter.getDefaultAdapter();//get the mobile bluetooth device BluetoothDevice dispositivo = myBluetooth.getRemoteDevice(address);//connects to the device's address and checks if it's available btSocket = dispositivo.createInsecureRfcommSocketToServiceRecord(myUUID);//create a RFCOMM (SPP) connection BluetoothAdapter.getDefaultAdapter().cancelDiscovery(); btSocket.connect();//start connection } } catch (IOException e) { ConnectSuccess = false;//if the try failed, you can check the exception here } return null; }
Example 3
Source File: GrblBluetoothSerialService.java From grblcontroller with GNU General Public License v3.0 | 6 votes |
public ConnectThread(BluetoothDevice device, boolean secure) { mmDevice = device; BluetoothSocket tmp = null; mSocketType = secure ? "Secure" : "Insecure"; try { if (secure) { tmp = device.createRfcommSocketToServiceRecord(MY_UUID_SECURE); } else { tmp = device.createInsecureRfcommSocketToServiceRecord(MY_UUID_INSECURE); } } catch (IOException | NullPointerException e) { Log.e(TAG, "Socket Type: " + mSocketType + "create() failed", e); } mmSocket = tmp; mState = STATE_CONNECTING; }
Example 4
Source File: MyActivity.java From AndroidLEDcontrol with MIT License | 6 votes |
void connect2LED(BluetoothDevice device) { UUID uuid = UUID.fromString("00001101-0000-1000-8000-00805f9b34fb") ; try { blsocket = device.createInsecureRfcommSocketToServiceRecord(uuid); blsocket.connect(); pairedBluetoothDevice = device; bluetoothPaired.setText("PAIRED: "+device.getName()); bluetoothPaired.setTextColor(getResources().getColor(R.color.green)); Toast.makeText(getApplicationContext(), "Device paired successfully!",Toast.LENGTH_LONG).show(); }catch(IOException ioe) { Log.e("taha>", "cannot connect to device :( " +ioe); Toast.makeText(getApplicationContext(), "Could not connect",Toast.LENGTH_LONG).show(); pairedBluetoothDevice = null; } }
Example 5
Source File: BluetoothClientService.java From tilt-game-android with MIT License | 6 votes |
public ConnectThread(BluetoothDevice device, boolean secure) { _device = device; _socketType = secure ? "Secure" : "Insecure"; BluetoothSocket socket = null; // Get a BluetoothSocket for a connection with the // given BluetoothDevice try { if (secure) { socket = device.createRfcommSocketToServiceRecord(_secureUuid); } else { socket = device.createInsecureRfcommSocketToServiceRecord(_insecureUuid); } } catch (IOException e) { Log.e(TAG, "ConnectThread: create failed"); e.printStackTrace(); } _socket = socket; }
Example 6
Source File: BluetoothService.java From AndroidSmoothBluetooth with Apache License 2.0 | 6 votes |
public ConnectThread(BluetoothDevice device) { mmDevice = device; BluetoothSocket tmp = null; // Get a BluetoothSocket for a connection with the // given BluetoothDevice try { if (mIsSecure) { if (isAndroid) { tmp = device.createRfcommSocketToServiceRecord(UUID_ANDROID_DEVICE); } else { tmp = device.createRfcommSocketToServiceRecord(UUID_OTHER_DEVICE); } } else { if (isAndroid) { tmp = device.createInsecureRfcommSocketToServiceRecord(UUID_ANDROID_DEVICE); } else { tmp = device.createInsecureRfcommSocketToServiceRecord(UUID_OTHER_DEVICE); } } } catch (IOException e) { } mmSocket = tmp; }
Example 7
Source File: BluetoothChatService.java From android-BluetoothChat with Apache License 2.0 | 6 votes |
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; }
Example 8
Source File: BluetoothManager.java From libcommon with Apache License 2.0 | 5 votes |
/** * ConnectingThread用のBluetoothSocketを生成するためのヘルパーメソッド * @param device * @param secure セキュア接続用のBluetoothSocketを生成するならtrue * @return */ private BluetoothSocket createBluetoothSocket(final BluetoothDevice device, final boolean secure) throws IOException { // 接続を行うためのBluetoothSocketを生成 return secure ? device.createRfcommSocketToServiceRecord(mSecureProfileUUID) // セキュア接続 : device.createInsecureRfcommSocketToServiceRecord(mInSecureProfileUUID); // インセキュア接続 }
Example 9
Source File: Api10Adapter.java From mytracks with Apache License 2.0 | 5 votes |
@Override public BluetoothSocket getBluetoothSocket(BluetoothDevice bluetoothDevice) throws IOException { try { return bluetoothDevice.createInsecureRfcommSocketToServiceRecord( BluetoothConnectionManager.MY_TRACKS_UUID); } catch (IOException e) { Log.d(TAG, "Unable to create insecure connection", e); } return bluetoothDevice.createRfcommSocketToServiceRecord(BluetoothConnectionManager.MY_TRACKS_UUID); }
Example 10
Source File: BluetoothIOGateway.java From ELM327 with Apache License 2.0 | 5 votes |
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; }
Example 11
Source File: BtCommService.java From AndrOBD with GNU General Public License v3.0 | 5 votes |
BtConnectThread(BluetoothDevice device, boolean secure) { mmDevice = device; BluetoothSocket tmp = null; mSocketType = secure ? "Secure" : "Insecure"; // Modified to work with SPP Devices final UUID SPP_UUID = UUID .fromString("00001101-0000-1000-8000-00805F9B34FB"); // Get a BluetoothSocket for a connection with the // given BluetoothDevice try { if (secure) { tmp = device.createRfcommSocketToServiceRecord(SPP_UUID); } else { tmp = device.createInsecureRfcommSocketToServiceRecord(SPP_UUID); } } catch (IOException e) { log.log(Level.SEVERE, "Socket Type: " + mSocketType + "create() failed", e); } mmSocket = tmp; logSocketUuids(mmSocket, "BT socket"); }
Example 12
Source File: SyncStreamingService.java From boogie-board-sync-sdk-android with MIT License | 5 votes |
public ConnectThread(BluetoothDevice device) { BluetoothSocket tmp = null; // Get a BluetoothSocket for a connection with the given BluetoothDevice try { tmp = device.createInsecureRfcommSocketToServiceRecord(CONNECT_UUID); } catch (IOException e) { Log.e(TAG, "create() failed", e); } mSocket = tmp; }
Example 13
Source File: SyncFtpService.java From boogie-board-sync-sdk-android with MIT License | 5 votes |
public ConnectThread(BluetoothDevice device) { BluetoothSocket tmp = null; // Get a BluetoothSocket for a connection with the // given BluetoothDevice try { tmp = device.createInsecureRfcommSocketToServiceRecord(FTP_UUID); } catch (IOException e) { Log.e(TAG, "create() failed", e); } mSocket = tmp; }
Example 14
Source File: DirectMessageSession.java From gilgamesh with GNU General Public License v3.0 | 5 votes |
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; }
Example 15
Source File: ReadThread.java From brailleback with Apache License 2.0 | 4 votes |
private void tryToConnect(List<DeviceFinder.DeviceInfo> bonded) { mSocket = null; try { for (DeviceFinder.DeviceInfo dev : bonded) { if (mDisconnecting) { return; } BluetoothDevice bthDev = dev.getBluetoothDevice(); if (mBluetoothAddressToConnectTo != null && !mBluetoothAddressToConnectTo.equals( bthDev.getAddress())) { continue; } mDisplayService.setConnectionProgress( mResources.getString(R.string.connprog_trying, bthDev.getName())); Log.d(LOG_TAG, "Trying to connect to braille device: " + bthDev.getName()); try { BluetoothSocket socket; if (dev.getConnectSecurely()) { socket = bthDev .createRfcommSocketToServiceRecord( dev.getSdpUuid()); } else { socket = bthDev .createInsecureRfcommSocketToServiceRecord( dev.getSdpUuid()); } if (socket != null) { socket.connect(); mSocket = socket; mConnectedDeviceInfo = dev; } return; } catch (IOException ex) { Log.e(LOG_TAG, "Error opening a socket: " + ex.toString()); } } } finally { if (mSocket == null) { mDisplayService.setConnectionProgress(null); } } }