I’m trying to send and receive binary data sms from my app (sdk 2.1-update 1), with no luck
I have set up the following receivers in the manifest:
<receiver android:name=".MainReceiver">
<intent-filter android:priority="10">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<receiver android:name=".MainReceiver">
<intent-filter android:priority="10">
<action android:name="android.intent.action.DATA_SMS_RECEIVED" />
</intent-filter>
</receiver>
I tried with and without the data tags for the action DATA_SMS_RECEIVED:
<data android:scheme="sms"/>
<data android:host="localhost"/>
<data android:port="16001"/>
I specified all the permissions i could related to sending/receiving/reading SMS, or MMS, etc.. just to be sure it isn’t a permission issue..
I’m sending an sms, and a data sms, from emulator on port 5556, to emulator on port 5554.
Emulator 5554 receives the ordinary sms without problems, but it doesn’t receive the data sms, and nothing shows up in the inbox either..
maybe it’s never sent, this is the sample code that sends the sms:
SmsManager mgr = SmsManager.getDefault();
mgr.sendTextMessage("5554", null, "message", null, null);
mgr.sendDataMessage("5554", null, (short) 16001, "message".getBytes(), null, null);
The broadcast receiver just shows a Toast message when it receives something.
I’ve spent 5 hours trying every possibile combination of receivers, data tags, port numbers, absolutely nothing has ever been received as data sms..
I’m out of ideas, really..
It seems like emulators doesn’t work well with data sms.. they don’t throw any exception but they don’t send the data messages. For this reason, sendDataMessage() seems to work fine because it doesn’t throw any error, but the truth is that it just doesn’t send anything!
Using a device, everything works well!