synchronized (ConnectorOpenMonitor) { String url = "btspp://00027207698F:1;authenticate=false;encrypt=false;master=false"; //+ myService.toString() try { form.setTitle("0"); if(connection!=null) { connection.close(); connection = null; } connection = (StreamConnection) Connector.open(url, Connector.READ_WRITE, true); form.setTitle("01"); is = connection.openDataInputStream(); os = connection.openDataOutputStream(); form.setTitle("02"); form.setTitle("03"); os.writeUTF("img"); form.setTitle("03a"+Integer.toString(imageData.length)); os.writeInt(imageData.length); form.setTitle("03b"+Integer.toString(imageData.length)); os.write(imageData); os.flush(); // read data from the server form.setTitle("03d"); form.setTitle("04"); if (is != null) { is.close(); } if (os != null) { os.close(); } connection.close(); System.gc(); form.setTitle("05"); } catch (Exception e) { form.setTicker(new Ticker(e.toString())); e.printStackTrace(); } }