Click here to Skip to main content
15,887,083 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using Bluecove to send files to mobile .. my code work fine with nokia phones but with sony ericsson i get stuck at the file sending ... it doesnt start .. the phone shows bluetooth activity but it never ask to confirm the connection ...I'm honestly not sure where it goes wrong


 public class send   implements Runnable {
        private String filename ;
        private byte[] file;
        private String btconnectionurl;
    public send(String filename, byte[] file, String btconnectionurl) {
        this.filename = filename;
        this.file = file;
        this.btconnectionurl = "btgoep://"+btconnectionurl + ":9";

    }
    public void run() {
        //com.intel.bluetooth.BlueCoveImpl.setConfigProperty("bluecove.connect.timeout", "5000");
        // com.intel.bluetooth.BlueCoveImpl.setConfigProperty("bluecove.obex.timeout", "3000");
         com.intel.bluetooth.BlueCoveImpl.setConfigProperty("bluecove.obex.mtu", "3840");
         try{
            Connection Con = (Connection) Connector.open(btconnectionurl,javax.microedition.io.Connector.READ_WRITE,true);
            ClientSession clientsession = (ClientSession) Con ;//nector.open(btconnectionurl,javax.microedition.io.Connector.READ_WRITE,true);
            HeaderSet header = clientsession.createHeaderSet();
          
            header.setHeader(HeaderSet.NAME, filename);
            header.setHeader(HeaderSet.TYPE, "text");
            header.setHeader(HeaderSet.LENGTH, new Long(file.length));
            clientsession.connect(header);
            Operation putOperation = clientsession.put(header);

            OutputStream outputStream = putOperation.openOutputStream();
            outputStream.write(file);
            outputStream.close();
            putOperation.close();
            clientsession.disconnect(null);
            

        } catch (Exception ex) {
            Logger.getLogger(send.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}com.intel.bluetooth.BlueCoveImpl.setConfigProperty("bluecove.connect.timeout", "5000");
        // com.intel.bluetooth.BlueCoveImpl.setConfigProperty("bluecove.obex.timeout", "3000");
         com.intel.bluetooth.BlueCoveImpl.setConfigProperty("bluecove.obex.mtu", "3840");
         try{
            Connection Con = (Connection) Connector.open(btconnectionurl,javax.microedition.io.Connector.READ_WRITE,true);
            ClientSession clientsession = (ClientSession) Con ;//nector.open(btconnectionurl,javax.microedition.io.Connector.READ_WRITE,true);
            HeaderSet header = clientsession.createHeaderSet();
             ////this area need fliping
            header.setHeader(HeaderSet.NAME, filename);
            header.setHeader(HeaderSet.TYPE, "text");
            header.setHeader(HeaderSet.LENGTH, new Long(file.length));
            clientsession.connect(header);
            Operation putOperation = clientsession.put(header);

            OutputStream outputStream = putOperation.openOutputStream();
            outputStream.write(file);
            outputStream.close();
            putOperation.close();
            clientsession.disconnect(null);
            

        } catch (Exception ex) {
            Logger.getLogger(send.class.getName()).log(Level.SEVERE, null, ex);
        }
Posted
Comments
Nagy Vilmos 5-Nov-10 6:06am    
Was an exception thrown? What was it?
Can you provide an answer or delete this question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900