Guest User

Untitled

a guest
Jun 21st, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.02 KB | None | 0 0
  1. public void Conection()
  2. {
  3. // try {
  4. BluetoothDevice device = btAdapter.getRemoteDevice(MacAddress);
  5.  
  6. Log.d(LOG_TAG, "***Получили удаленный Device***" + device.getName());
  7. try {
  8. btSocket = device.createRfcommSocketToServiceRecord(MY_UUID);
  9. Log.d(LOG_TAG, "...Создали сокет...");
  10. } catch (IOException e) {
  11.  
  12. }
  13.  
  14. btAdapter.cancelDiscovery();
  15. Log.d(LOG_TAG, "***Отменили поиск других устройств***");
  16.  
  17. Log.d(LOG_TAG, "***Соединяемся...***");
  18. try {
  19. btSocket.connect();
  20.  
  21. try {
  22. Intent intentErrorSertch = new Intent(ErrorSertch.this, Home.class);
  23. startActivity(intentErrorSertch);
  24. } catch (Exception e) {
  25. }
  26.  
  27.  
  28. Log.d(LOG_TAG, "***Соединение успешно установлено***");
  29. } catch (IOException e) {
  30. try {
  31. btSocket.close();
  32. bat.setVisibility(View.VISIBLE);
  33. } catch (IOException e2) {
  34.  
  35. }
  36. }
Add Comment
Please, Sign In to add comment