On this post I will explain how to send a short message text (SMS) in only 4 steps.
1. First we have to import this libraries
import java.io.IOException;
import java.io.InterruptedIOException;
import javax.microedition.io.Connector;
import javax.wireless.messaging.*;
2. The next step is open a connection to the sms port
// Set the destination number
String sNumber = "1131733116";
MessageConnection messageConnection = null;
String sAddress = "sms://" + sNumber;
try
{
messageConnection = (MessageConnection)Connector.open(sAddress);
}
catch (IOException ex)
{
// handle exception
}
3. Then, with the connection opened, we have to send the SMS message
// This the message that we will send
String sMessage = "Hi there!!";
// Creates a new TextMessage
TextMessage textMessage = (TextMessage)messageConnection.newMessage(MessageConnection.TEXT_MESSAGE);
textMessage.setPayloadText(sMessage);
// Send the message
try
{
messageConnection.send(textMessage);
}
catch (IOException ex)
{
// handle exception
}
4. Finally we have to close the opened connection
if (messageConnection != null)
{
try
{
messageConnection.setMessageListener(null);
messageConnection.close();
}
catch (Exception e)
{
// handle exception
}
}

i just hav 2 paste this code in netbeans or wireless toolkit and run it with my mobile bluetooth activated? will this work? thanks ..
Hi amar,
I dont get your doubt, this code is to send SMS over SMS protocol not for bluetooth. If I am not clear please let me known.
Best,
Pablo
hi..do you know how to send text via bluetooth ? Do you have any sources codes related to this purpose?
There is not a way to send only text like a SMS message, you should to send a file .txt over OBEX meybe. I recomend you read about OBEX.
Best,
Pablo