You Are Here:

Community: Developer Discussion Boards

#1 Old J2ME Bluetooth tutorial - 2006-09-30, 21:02

Join Date: Sep 2006
Posts: 1
pichalsi
Offline
Registered User
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?
Reply With Quote

#2 Old Re: J2ME Bluetooth tutorial - 2009-07-07, 15:31

Join Date: Mar 2009
Posts: 33
shashankgr8
Offline
Registered User
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();
}
}
}
Reply With Quote

#3 Old Re: J2ME Bluetooth tutorial - 2009-07-09, 13:50

Join Date: Mar 2008
Posts: 577
mahbub_s60's Avatar
mahbub_s60
Offline
Forum Nokia Expert
You could check this also
http://www.forum.nokia.com/info/sw.n..._0_en.zip.html


-Mahbub
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
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

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia