Avoid potential, but very unlikely NPE

here
cpfeiffer 2015-11-23 21:59:13 +01:00
parent 4622b384f2
commit 394a0905dc
1 changed files with 9 additions and 7 deletions

View File

@ -36,13 +36,15 @@ public class SMSReceiver extends BroadcastReceiver {
Bundle bundle = intent.getExtras();
if (bundle != null) {
Object[] pdus = (Object[]) bundle.get("pdus");
for (Object pdu1 : pdus) {
byte[] pdu = (byte[]) pdu1;
SmsMessage message = SmsMessage.createFromPdu(pdu);
notificationSpec.body = message.getDisplayMessageBody();
notificationSpec.phoneNumber = message.getOriginatingAddress();
if (notificationSpec.phoneNumber != null) {
GBApplication.deviceService().onNotification(notificationSpec);
if (pdus != null) {
for (Object pdu1 : pdus) {
byte[] pdu = (byte[]) pdu1;
SmsMessage message = SmsMessage.createFromPdu(pdu);
notificationSpec.body = message.getDisplayMessageBody();
notificationSpec.phoneNumber = message.getOriginatingAddress();
if (notificationSpec.phoneNumber != null) {
GBApplication.deviceService().onNotification(notificationSpec);
}
}
}
}