On Apr 18, 7:52 am, kaloer <[email protected]> wrote:
> Hi,
> Is it possible to get the phone number of a received sms within code?
> Look at this example at the if-statement:
>
>         @Override
>     public void onReceive(Context context, Intent intent) {
>         Bundle bundle = intent.getExtras();
>         Object messages[] = (Object[]) bundle.get("pdus");
>         SmsMessage smsMessage[] = new SmsMessage[messages.length];
>         for (int n = 0; n < messages.length; n++) {
>             smsMessage[n] = SmsMessage.createFromPdu((byte[]) messages
> [n]);
>         }
>
        String from= smsMessage[n].getOriginatingAddress();
        if(from.contains("8501234567"))
...



>         if([HOW DO I GET THE NUMBER]) {
>         Toast toast = Toast.makeText(context, "New SMS: " + smsMessage
> [0].getMessageBody(), Toast.LENGTH_LONG);
>         toast.show();
>         }
>     }
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Beginners" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-beginners?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to