Java me netbeans bluetooth application sending a picture problem, it doesnt send the picture to the recieving phone but the phone is detected, when i send it, gives message error "dont find any record" it shows the other phone name emlname once i click send it lags for a while ant gives the error "dont find any record"
public void serviceSearchCompleted(int i, int i0) {
String message = "";
switch(i0){
case DiscoveryListener.SERVICE_SEARCH_COMPLETED:
if(sr != null){
devices.setTitle("sending picture...");
handle = new ClientHandle();
return;
}
case DiscoveryListener.SERVICE_SEARCH_NO_RECORDS:
message = "don't find any record";
break;
default:
break;
}
devices.setTitle("no service");
Alert a = BTMIDlet.getAlert(message,AlertType.INFO,2000);
Display.getDisplay(midlet).setCurrent(a);
public void commandAction(Command command, Displayable displayable) {
if(command.getCommandType() == Command.BACK){
}
if(command == List.SELECT_COMMAND){
int i = devices.getSelectedIndex();
UUID[] uuids = new UUID[1];
uuids[0] = new UUID(0x0001);
try {
devices.setTitle("looking for services...");
bt.getDiscoveryAgent().searchServices(null,uuids,(RemoteDevice)deviceVector.elementAt(i),this);
} catch (BluetoothStateException ex) {
ex.printStackTrace();
showException(ex);
}
}
}
public void run(){
String url = sr.getConnectionURL(ServiceRecord.NOAUTHENTICATE_NOENCRYPT,false);
int i = url.indexOf(":");
String protocol = url.substring(0,i);
if(protocol.equals("btspp")){
StreamConnection conn = null;
try {
conn = (StreamConnection)Connector.open(url);
OutputStream os = conn.openOutputStream();
os.write(midlet.getImage());
os.flush();
os.close();
conn.close();
} catch (IOException ex) {
ex.printStackTrace();
}
}else if(protocol.equals("btl2cap")){
L2CAPConnection conn = null;
try{
conn = (L2CAPConnection)Connector.open(url);
int max = conn.getTransmitMTU();
byte[] img = midlet.getImage();
byte[] buffer = new byte[max];
int index = 0;
while(index <img.length){
if(img.length - index<max){>
buffer = new byte[img.length-index];
System.arraycopy(img,index,buffer,0,img.length-index);
}else{
System.arraycopy(img,index,buffer,0,max);
}
conn.send(buffer);
index+=max;
}
conn.close();
} catch (Exception ex) {
showException(ex);
}
}
}
}
}