Hi Avron,

Thank you very much, just what i was looking for :)

//Kaloer

On 19 Apr., 17:05, avrono <[email protected]> wrote:
> Kaloer,
>
> You need to set a URI to the SMS Inbox Content and then create a
> cursor (i.e a query to the the SQLLite DB) and iterate over it.
>
> If you are in your activity, it would be somthing like
>
> this.getContentResolver().query(
>                                 Uri.parse("content://sms/inbox"), null, null, 
> null, null);
>
> You then have access to the full SMS content and phone number etc.
>
> Hope this helps !
>
> Avron
>
> On Apr 18, 8: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]);
> >         }
>
> >         if([HOW DO I GET THE NUMBER]) {
> >         Toast toast = Toast.makeText(context, "New SMS: " + smsMessage
> > [0].getMessageBody(), Toast.LENGTH_LONG);
> >         toast.show();
> >         }
> >     }
>
> > Thank you very much!
>
> > Best regards
> > Kaloer
--~--~---------~--~----~------------~-------~--~----~
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