S
Saim_xF
Neues Mitglied
- 0
Hallo!
Meine App soll sich mit einem gekoppelten Gerät verbinden per Klick auf die List view! Welche UUID soll ich verwenden? Bitte um Hilfe!
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View lv,int position, long id) {
// When clicked, show a toast with the TextView text
Device neu = list.get(position);
BluetoothDevice btDevice;
BluetoothSocket tmp = null;
BluetoothSocket mSocket;
String adress = neu.getAdress();
UUID uuid;
uuid = UUID.fromString("00001101-0000-1000-00805F9B34FB");
btDevice = mBluetoothAdapter.getRemoteDevice(adress);
try {
tmp = btDevice.createRfcommSocketToServiceRecord(uuid);
} catch (IOException e) {
// TODO Auto-generated catch block
tv.setText("fail bei creating btDevice !!!");
//e.printStackTrace();
}
mSocket = tmp;
//mBluetoothAdapter.cancelDiscovery();
// Make a connection to the BluetoothSocket
try {
// This is a blocking call and will only return on a
tmp.connect();
} catch (IOException e1) {
// Close the socket
tv.setText("fail bei connecting btDevice !!!");
try {
mSocket.close();
} catch (IOException e2) {
tv.setText("fail bei disconnecting btDevice !!!");
}
}
}
});
Meine App soll sich mit einem gekoppelten Gerät verbinden per Klick auf die List view! Welche UUID soll ich verwenden? Bitte um Hilfe!
lv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> parent, View lv,int position, long id) {
// When clicked, show a toast with the TextView text
Device neu = list.get(position);
BluetoothDevice btDevice;
BluetoothSocket tmp = null;
BluetoothSocket mSocket;
String adress = neu.getAdress();
UUID uuid;
uuid = UUID.fromString("00001101-0000-1000-00805F9B34FB");
btDevice = mBluetoothAdapter.getRemoteDevice(adress);
try {
tmp = btDevice.createRfcommSocketToServiceRecord(uuid);
} catch (IOException e) {
// TODO Auto-generated catch block
tv.setText("fail bei creating btDevice !!!");
//e.printStackTrace();
}
mSocket = tmp;
//mBluetoothAdapter.cancelDiscovery();
// Make a connection to the BluetoothSocket
try {
// This is a blocking call and will only return on a
tmp.connect();
} catch (IOException e1) {
// Close the socket
tv.setText("fail bei connecting btDevice !!!");
try {
mSocket.close();
} catch (IOException e2) {
tv.setText("fail bei disconnecting btDevice !!!");
}
}
}
});