My BroadcastReceiver
works just fine when the device receives an SMS from another regular phone, but if the SMS is sent through the carrier's e-mail gateway like "[email protected]", then the message is received on the device normally as an SMS, but the android.provider.Telephony.SMS_RECEIVED
action does not fire and my BroadcatReceiver
never gets notified. Is there something I'm missing?
<receiver android:name=".services.IncomingSmsBroadcastReceiver" >
<intent-filter android:priority="2147483647" >
<action android:name="android.provider.Telephony.SMS_RECEIVED" >
</action>
</intent-filter>
</receiver>
I found something interesting about how carriers handle e-mails, which in turn was causing wrong behavior in my if
statements, which in turn caused the problem stated in this question.
Apparently, when cell phone service providers handle e-mails to your phone, they send it through a random short number: like 4043 for example. In your BroadcastReceiver
, when you get a hold of the SmsMessage
, you should always use SmsMessage.getDisplayOriginatingAddress()
and SmsMessage.getDisplayMessageBody()
. These will give you the e-mail address that sent it and the proper body respectively. Unlike SmsMessage.getOriginatingAddress()
and SmsMessage.getMessageBody()
which will give you instead the random number mentioned previously and the body containing the e-mail address mixed up with the actual content.