use of csacre15.ipl.be.myapp.Builder in project Synthese_2BIN by TheYoungSensei.
the class SMSReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
MyModel mainModel = ((Builder) context.getApplicationContext()).getModel();
Bundle bundle = intent.getExtras();
Object[] pdus = (Object[]) bundle.get("pdus");
SmsMessage[] messages = new SmsMessage[pdus.length];
String message = "";
String tel = "";
for (int i = 0; i < pdus.length; i++) {
messages[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
message += messages[i].getMessageBody();
tel = messages[i].getOriginatingAddress();
}
String[] decoded = message.split(";");
if (decoded[0].equalsIgnoreCase("#laFete")) {
if (decoded.length != 4) {
Toast.makeText(context, "Petit Coquin", Toast.LENGTH_LONG).show();
} else {
mainModel.ajouterUtil(decoded[1], decoded[2], decoded[3], tel);
}
} else {
Toast.makeText(context, "Petit Coquin", Toast.LENGTH_LONG).show();
}
}
Aggregations