Bluetooth接続を作成しようとしています。Bluetooth接続が失敗しました:読み込みに失敗しました。ソケットが閉じているかタイムアウトしました。読み込みret:-1
私は近くのデバイスを検索することができますが、私は、私はエラーを取得する接続しようとすると、私は理解していない:
LOGCAT
01-03 00:55:06.909 6654-6654/com.bluetooth.prova3.listdiscovery D/CONNECTTHREAD: Could not close connection:java.io.IOException: read failed, socket might closed or timeout, read ret: -1
を、私は、接続するデバイスを受けるものを2つのクラスを持って、接続を実行し、もう一方をmake接続に使用します。
ConexionActivity.Java
package com.bluetooth.prova3.listdiscovery;
***Imports*****
public class ConexionActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_conexion);
//Aqui rebo el dispositiu que he seleccionat per conectarme
Intent intent = getIntent();
BluetoothDevice bluetoothDevice = intent.getExtras().getParcelable("btdevice");
//mostro el nom per la pantalla amb un text view
TextView MacAddress = (TextView)findViewById(R.id.MAC);
String aaaa = bluetoothDevice.getName() + "\n" + bluetoothDevice.getAddress();
MacAddress.setText(aaaa);
ConnectThread conexion = new ConnectThread(bluetoothDevice);
conexion.run();
}
}
ConnectThread.java
package com.bluetooth.prova3.listdiscovery;
輸入
ありがとう!
prateek、答えてくれてありがとう、私はlogcatで同じエラーを取得します。 –
UUID MY_UUID = UUID.fromString( "00001101-0000-1000-8000-00805F9B34FB");このUUIDを試してみてください。 – Prateek
それは仕事です!ありがとう!問題はrandomUUID()にありましたか? –