Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BluetoothAdapter blue = BluetoothAdapter.getDefaultAdapter();
- for(int index =0; index<adressAndID.length;index++){
- // Verbindung herstellen
- BluetoothDevice dev = blue.getRemoteDevice(adressAndID[index][0]);
- try {
- UUID id1 = UUID
- .fromString("00001101-0000-1000-8000-00805F9B34FB");
- if(sock!=null)
- sock.close();
- Log.i("Status:", "vor connect");
- Method m = dev.getClass().getMethod("createRfcommSocket", new Class[] {int.class}); sock = (BluetoothSocket) m.invoke(dev, 1);
- try{
- sock.connect();
- }catch(IOException i)
- {
- try{
- sock.connect();
- }catch(IOException ea)
- {
- sock.connect();
- }
- }
- Log.i("Status:", "nach connect");
- in = new Scanner(sock.getInputStream());
- OutputStream out = sock.getOutputStream();
- // Verbunden
- String start = "123;";
- out.write(start.getBytes());
- //Hier passiert viel Datenverarbeitung
- publishProgress("Vorgang abgeschlossen.");
- //Socket schlieΓen
- in.close();
- out.close();
- //out.flush();
- sock.close();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement