Thursday, June 21, 2007

J2ME BlueTooth programming(Episode 2)

1 comment:

Dundi said...

Hi,

I am kusuma,
And I need your help to complete my task that I would like explain here.
Scenario:I have to send request from mobile to pc from there to database and retrieve coreesponding response from pc to mobile via bluetooth connection.After getting response i m send another request to pc via bluetooth which fails in connection
connection value null.

here is my code


[code]

StreamConnection con = null;
Form ff = new Form("Connection");
try {
isBTConnected = false;

try {
con = (StreamConnection) Connector.open(mConnectionUrl);
} catch (Exception ee) {
ff.append("conn exc" + ee);
SLIM.display.setCurrent(ff);
}

try {
outputstream = con.openOutputStream();
outputstream.write(req.getBytes());
outputstream.flush();
} catch (Exception eee) {
ff.append("out exc" + eee);
SLIM.display.setCurrent(ff);
}
slimResponse = readImageName(con);

ff.append("req" + req);
ff.append("stream" + outputstream);
ff.append("conn" + con);
SLIM.display.setCurrent(ff);
manager.SLIMResponse(parseString(slimResponse.trim()));
outputstream.close();
closeBTConnection();
} catch (Exception e) {
ff.append("Write Exception" + e);
SLIM.display.setCurrent(ff);
}

[/code]


Note :The url is not null.