From db31b1ab24c2f6418a4c2138eda5769b036b3302 Mon Sep 17 00:00:00 2001 From: topillar Date: Fri, 29 Nov 2019 13:52:39 +0800 Subject: [PATCH] Update SmsReceiver.java --- .../financisto/service/SmsReceiver.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/ru/orangesoftware/financisto/service/SmsReceiver.java b/app/src/main/java/ru/orangesoftware/financisto/service/SmsReceiver.java index 1f2891bd..59542739 100644 --- a/app/src/main/java/ru/orangesoftware/financisto/service/SmsReceiver.java +++ b/app/src/main/java/ru/orangesoftware/financisto/service/SmsReceiver.java @@ -34,14 +34,22 @@ public void onReceive(final Context context, final Intent intent) { SmsMessage msg = null; String addr = null; + String taddr = null; final StringBuilder body = new StringBuilder(); for (final Object one : msgs) { msg = SmsMessage.createFromPdu((byte[]) one); addr = msg.getOriginatingAddress(); - if (smsNumbers.contains(addr)) { + /*if (smsNumbers.contains(addr)) { body.append(msg.getDisplayMessageBody()); - } + }*/ + for( Object two : smsNumbers) { + taddr = two.toString(); + if(addr.startsWith(taddr)){ + body.append(msg.getDisplayMessageBody()); + break; + } + } } final String fullSmsBody = body.toString(); @@ -49,7 +57,7 @@ public void onReceive(final Context context, final Intent intent) { Log.d(FTAG, format("%s sms from %s: `%s`", msg.getTimestampMillis(), addr, fullSmsBody)); Intent serviceIntent = new Intent(ACTION_NEW_TRANSACTION_SMS, null, context, FinancistoService.class); - serviceIntent.putExtra(SMS_TRANSACTION_NUMBER, addr); + serviceIntent.putExtra(SMS_TRANSACTION_NUMBER, taddr); serviceIntent.putExtra(SMS_TRANSACTION_BODY, fullSmsBody); FinancistoService.enqueueWork(context, serviceIntent); }