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); is = connection.openDataInputStream(); os = connection.openDataOutputStream(); os.writeUTF("img"); os.writeInt(imageData.length); int i = 0; int mmtu = 4096; int len = 0; while (i * mmtu <= imageData.length) { len = (i + 1) * mmtu <= imageData.length ? mmtu : imageData.length - i * mmtu; os.write(imageData,i,len); i++; } //os.flush(); //os.write(imageData); if (connection != null) { is.close(); os.close(); connection.close(); } } catch (Exception e) { form.setTicker(new Ticker(e.toString())); e.printStackTrace(); } }