0

I am developing an android application, which has to respond to a certain SMS message.

The message must be as follows:

  • It must come from a particular number, already known to the application.
  • It must contain a certain code as the text.

If both of these are satisfied, then the code in the SMS should be displayed inside a particular button object in the application.

Can anyone please help me do this? I just need to get the way to do this.

Dave L.
  • 9,595
  • 7
  • 43
  • 69
  • 1
    Welcome to SO! It's best to show some code or explain what you have done already. Most users of SO are more than happy to help given you have provided significant effort. – Justin Self Jan 22 '12 at 04:12

2 Answers2

0

The following article describes sending and receiving SMS with Android: http://mobiforge.com/developing/story/sms-messaging-android

Stefan
  • 4,645
  • 1
  • 19
  • 35
0

First of all, there's no official API to work with SMS, but still there's some way around that (though you don't have ANY guarantee it will work on all vendor's devices).

See the link presented by @Stefan to understand how you can intercept SMSes.

Than you need to parse the number (getOriginatingAddress()). If that satisfies your criteria, parse the SMS body for your code-word (getMessageBody().toString()).

Latest, if all criteria are met, you have to acquire reference to your button object (findViewById(R.id.) and change the text using setText("your text").

Consider having the button positioned in your layout with visibility attribute set to "invisible" and when you set the text, change the visibility attribute to "visible" (not sure if you need it like this).

hovanessyan
  • 30,580
  • 6
  • 55
  • 83