An App receives an SMS and from the text performs a function. For this it is necessary to read the SMS and to make the comparison in the APP, but for this it is due read, word by word, line by line or make a comparison if it contains such a word in this SMS.
SMS will have the following content.
If a status change occurs:
MONIT-110
E05-ATI
E06-DES
And that of all outputs:
STATUS-110
E01-DES
E02-DES
E03-DES
E04-DES
E05-DES
E06-DES
E07-DES
E08-DES
E09-DES
E10-DES
E11-DES
S01-DES
S02-DES
S03-DES
S04-DES
S05-DES
S06-DES
For each of these lines you have a different command to execute.
Responsible MSG code received:
public class ReceberSms extends BroadcastReceiver {
private static final String CATEGORIA = "acqua";
@Override
public void onReceive(Context context, Intent intent) {
Log.i(CATEGORIA, ">" + intent.getAction());
Sms sms = new Sms();
//Lê a mensagem
SmsMessage msg = sms.receberMensagem(intent);
String celular = msg.getDisplayOriginatingAddress();
String mensagem = msg.getDisplayMessageBody();
//pegar essa msg e jogar nas configurações
String texto = "ReceberSms: recebeu sms[" + celular + "] -> " + mensagem;
Log.i(CATEGORIA, texto);
Toast.makeText(context, texto, Toast.LENGTH_SHORT).show();
}
}//fim