| Reply | « Previous Thread | Next Thread » |
|
Hi,
i hope i dont post in bad forum. I programmed a little bit in J2ME before and now ive decided i want to connect my j2me midlet with pc, i think it should be possible through bluetooth serial port profile, but i could not find any sample code, i mean, really simple just to send some text to hyperterminal or windows application waiting on com port. is there any? or maybe some tutorial or book? will i need some special ide for bluetooth j2me programming or not? |
|
here is the code
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import javax.microedition.io.Connector; import javax.microedition.io.StreamConnection; import javax.microedition.lcdui.Alert; import javax.microedition.lcdui.AlertType; import DrawingController.Drawing; public class BluetoothConnection { private static BluetoothConnection instance=null; private StreamConnection stream=null; private final String url="btspp://0050C27FEFA9:1"; private String DatafrmServer=""; OutputStream oustream=null; InputStream istream=null; public static BluetoothConnection getInstance() { if(instance == null) instance=new BluetoothConnection(); return instance; } public void CreateNewConnection() throws IOException { try { stream = (StreamConnection) Connector.open(url); } catch (Exception e) { Alert alert = Drawing.DisplayAlert("Sorry : Unable To Create Bluetooth Connectivity",AlertType.ERROR); Drawing.setDisplayble(alert); } } public String WriteBtData(String Data) throws IOException { System.err.println(Data + "Writtings" ); if(stream!=null) { DatafrmServer = ""; int enddata=255; oustream = stream.openOutputStream(); oustream.write(Data.getBytes()); oustream.write(enddata); oustream.close(); istream = stream.openInputStream(); int ch=255; while((ch = istream.read())!=enddata) { DatafrmServer+=(char)ch; } istream.close(); } return DatafrmServer; } public void CloseOpenConnection() { try { if(stream!=null) stream.close(); stream = null; } catch (Exception e) { e.printStackTrace(); } } } |
| shashankgr8 |
| View Public Profile |
| Find all posts by shashankgr8 |
|
You could check this also
http://www.forum.nokia.com/info/sw.n..._0_en.zip.html -Mahbub |
| mahbub_s60 |
| View Public Profile |
| Find all posts by mahbub_s60 |
| Reply | « Previous Thread | Next Thread » |
| Thread Tools | Search this Thread |
|---|---|
| Thread | Thread Starter | Forum | Replies | Last Post |
|---|---|---|---|---|
| nokia 6600, Bluetooth and J2ME | dleeICT | Bluetooth Technology | 2 | 2008-02-21 12:55 |
| J2ME bluetooth application | sepi1982 | Mobile Java Networking & Messaging & Security | 12 | 2006-10-19 16:36 |
| Bluetooth Programming in J2ME with 6600 | wing0custom | Mobile Java General | 3 | 2004-02-09 18:09 |
| Nokia 7650 support Bluetooth audo? | ovjo12 | Bluetooth Technology | 5 | 2003-07-17 19:50 |
| Can the Bluetooth in 6310i be progammed by J2ME? How? or how is it done? | mainul_2001 | Bluetooth Technology | 1 | 2002-09-12 09:29 |