El Trastero de Arien

miércoles, junio 10, 2009

Android: Send SMS

When I went to the Movilforum, a thing that many of the enterprises there told us was that SMS is a communication method that right now has a lot of possibilities and is not going to die in a near future.
So, the first thing I'm planning to do is to send SMS's with android (later I will link this feature with another one's). The class we are going to use is SmsManager. This class has a method called sendTextMessage that will send the sms. To our code we will have to add the following lines:

SmsManager SMSM = SmsManager.getDefault(); //Get the default instance of the SmsManager
SMSManager.sendTextMessage(destinationAddress, null, S, null, null);

And now let's explain a bit this commands:
in the sendTextMessage method, destinationAddress is a string that is going to be de address (mobile phone we want to send the sms) and S (probably here is not a quite good name) is another string that is the text of the SMS.
The rest of parameters we have set them to null, the first one is to indicate that we want to run with a default configuration, and the other two are to avoid confirmations of read and things like that.

P.D. In the simulator the string that we have to put as the destinationAddress is "myAvd:5554" for example, where 'myAvd' is how we have called the avd and the numbers are the number that appear up in the screen of the emulator.

Etiquetas: , , ,

1 comentarios:

Publicar un comentario

Suscribirse a Enviar comentarios [Atom]

<< Página principal