There's a bit of confusion upthread, so I'm just confirming that
Cristina's code sample works perfectly.

Using it you can listen for incoming SMS messages and extract each
message from the Intent. Thanks Christina!

Cheers
Reto Meier

-----
Professional Android Application Development
http://www.amazon.com/gp/product/0470344717?tag=interventione-20

On 24 Sep, 14:03, Cristina <[EMAIL PROTECTED]> wrote:
> Sorry I misundertand your message..
>
> Yes I have tried that part of the application (receiving a text sms)
> and works for me.
>
> I have send the message using the DDMS send utility...
> Maybe you can use the debugger in order to see if you are receiving
> the intent bundle with the extra "pdus"...
> Using the debugger I discovered that the intent bundle has this "pdus"
> extra, which is an Object[].
> Each Object[] element is a pdu (byte[])
>
> Can you see this using the debugger? Where is your application
> failing?
>
> Cristina
>
> On 24 sep, 14:20, "De San Nicolas Jean Philippe" <[EMAIL PROTECTED]>
> wrote:
>
>
>
> > Hello, I've tried your code but it failed! my application failed. Have you
> > tried and succeed?
>
> > 2008/9/24 Cristina <[EMAIL PROTECTED]>
>
> > > Hi,
>
> > > I do not know if it is the right way, but I have found a way to get
> > > the message.
> > > Here I include my code to get the SmsMessages. I hope it helps you
>
> > > public class ServerMessagesReceiver extends BroadcastReceiver {
>
> > >    static final String ACTION =
> > > "android.provider.Telephony.SMS_RECEIVED";
>
> > >    public void onReceive(Context context, Intent intent) {
> > >         if (intent.getAction().equals(ACTION)) {
> > >                 StringBuilder buf = new StringBuilder();
> > >                 Bundle bundle = intent.getExtras();
> > >                 if (bundle != null) {
> > >                         Object[] pdusObj = (Object[]) bundle.get("pdus");
> > >                         SmsMessage[] messages = new
> > > SmsMessage[pdusObj.length];
> > >                         for (int i = 0; i<pdusObj.length; i++) {
> > >                                 messages[i] = SmsMessage.createFromPdu
> > > ((byte[]) pdusObj[i]);
> > >                         }
> > > ....
> > > ....
> > > ...
>
> > > By the way, Does somebody know how to receive an SMS that has been
> > > sent using
> > > an application port using the methos.sendDataMessage?
>
> > > On 24 sep, 08:15, Reto Meier <[EMAIL PROTECTED]> wrote:
> > > > Is it still possible to listen for incoming SMS messages in the latest
> > > > 1.0 SDK release?
>
> > > > The SMS_RECEIVED_ACTION string used to listen for incoming SMS
> > > > messages seems to have gone missing. It used to be available from the
> > > > android.provider.Telephony.Sms package, which also seems to have
> > > > disappeared, so getMessagesFromIntent has gone too.
>
> > > > Previously, you could create a Broadcast Receiver to listen for SMS
> > > > messages using this code:
>
> > > >   String incoming_SMS =
> > > > android.provider.Telephony.Sms.Intents.SMS_RECEIVED_ACTION;
>
> > > >   public void onReceive(Context _context, Intent _intent) {
>
> > > >     if (_intent.getAction().equals(incoming_SMS)) {
> > > >       SmsManager sms = SmsManager.getDefault();
> > > >       SmsMessage[] messages =
> > > > Sms.Intents.getMessagesFromIntent(_intent);
> > > >     }
>
> > > > Is there still a way to do this?
>
> > > > Thanks
> > > > Reto- Ocultar texto de la cita -
>
> > - Mostrar texto de la cita -- Hide quoted text -
>
> - Show quoted text -
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to