DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: Bluetooth connection not working on US Nokia phones from J2ME Midlet (MIDP 2.0)

Hybrid View

  1. #1
    Join Date
    Jul 2009
    Posts
    2

    Bluetooth connection not working on US Nokia phones from J2ME Midlet (MIDP 2.0)

    Hi All,

    We are developing a J2ME midlet (MIDP 2.0 ,CLDC 1.1)which makes bluetooth connection to other devices.The bluetooth connection is working perfectly on indian nokia phones with Airtel as carrier.But when we deploy the same midlet on Nokia E71 US phone with carrier as AT&T ,the bluetooth connection is not working.The sample code is as follows:

    public void run(){

    try{
    StreamConnection connection = (StreamConnection)Connector.open(btConnectionURL);

    //
    // open an input stream to get some data
    //

    InputStream in = connection.openInputStream();

    byte[] serialData;
    readData = true;
    while(readData == true){
    int lengthavai=0;
    lengthavai = in.available();

    if(lengthavai > 0){

    serialData = new byte[lengthavai];
    int length = in.read(serialData);

    System.out.println("data read: " + new String(serialData));

    dataViewForm.append(new String(serialData));
    }
    }

    in.close();
    connection.close();

    }catch(IOException ioe){
    ioe.printStackTrace();
    }


    when we try to connect on US Phones,the execution hangs at the following line of code:
    StreamConnection connection = (StreamConnection)Connector.open(btConnectionURL);

    No exception is caught.

    Our midlet is not signed.

    In the Forums it is said that the problem is with the unsigned midlet.AS some of the US carriers block the secure API usage on Unsigned midlet.

    But our question is, if we buy a code signing certificate from Verisign or Thawte and sign the midlet, will this problem be solved.

    Any other alternative solutions for this ???

    Immediate help will be appreciated.


    Thanks,
    Mari Raja

  2. #2
    Join Date
    Apr 2008
    Location
    Finland
    Posts
    52
    No exception is caught usually means that the try-catch block is missing. Why not try something like this:

    Code:
    // open a connection to the server
    StreamConnection connection =
        (StreamConnection) Connector.open(url);
    // Send/receive data
    try {
        byte buffer[] = new byte[100];
        String msg = "hello there, server";
        InputStream is = connection.openInputStream();
        OutputStream os = connection.openOutputStream();
        // send data to the server
        os.write(msg.getBytes);
        // read data from the server
        is.read(buffer);
        connection.close();
    } catch(IOException e) {
      e.printStackTrace();
    }
    http://developers.sun.com/mobility/m...es/bluetooth2/

  3. #3
    Join Date
    Jul 2009
    Posts
    2

    Bluetooth connection not working on US Nokia phones from J2ME Midlet (MIDP 2.0)

    hi sypress,

    Thnaks for ur reply.
    I tried with ur code. But still i did not get any exception.
    when we try to connect on US Phones,the execution hangs at the following line of code:

    StreamConnection connection = (StreamConnection)Connector.open(btConnectionURL);


    I think, it is a problem with US phone operators.


    Thanks,
    A. Mari Raja

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center