views:

35

answers:

2

That's basically my question, I have written the code for sending/receiving SMS but it's basically a "server/client" so I can't get the SMS that are sent directly to the phone number instead of through the j2me program. Is it even possible?

A: 

It is quite possible to write an app that receives an incoming SMS, extracts the message and sends it to server through a HTTP call. You can then make that server send that SMS to another phone.

omermuhammed
how? I have a server and a client but I can't get normal SMS just those that go from client to server
Luis Armando
You can look up examples on the Internet to extract SMS message from an app directed SMS. Then just take that message and send it to server.
omermuhammed
A: 

Using the Wireless Messaging API (JSR 120) you can receive SMS to a JavaME application. However, you must register to receive SMS on a particular port, and you cannot read SMS from the phone's standard inbox.

Register:

import javax.wireless.messaging.MessageConnection;
MessageConnection connection = 
    (MessageConnection) javax.microedition.io.Connector.open("sms://:1234");

There are 2 different methods of receiving SMS:

  • event-driven using javax.wireless.messaging.MessageListener
  • using blocking method javax.wireless.messaging.MessageConnection.receive()
Alison
what do you mean "register"?? and How can a normal phone send the SMS so that the JavaME app gets it then? other than the client/server approach I have
Luis Armando
Hi Luis, you can't send SMS to a specific port using most standard phone interfaces (or any that I've seen). You *can* send ported SMS from one JavaME app to another, or from your "server" to a JavaME app. I've updated my answer to explain how to register for incoming messages.
Alison