to receive sms from a different port, set this receiver in your
AndroidManifest.xml
<receiver android:name=".SMSBcastReceiver">
<intent-filter android:priority="10">
<action android:name="android.intent.action.DATA_SMS_RECEIVED" />
<data android:scheme="sms" />
<data android:port="13013" />
</intent-filter>
</receiver>
then set this in your SMSBcastReceiver
class
public void onReceive(final Context context, Intent intent) {
Bundle bundle = intent.getExtras();
Object messages[] = (Object[]) bundle.get("pdus");
SmsMessage smsMessage[] = new SmsMessage[messages.length];
for (int n = 0; n < messages.length; n++)
{
smsMessage[n] = SmsMessage.createFromPdu((byte[]) messages[n]);
}
smsOrigin = smsMessage[0].getDisplayOriginatingAddress();
smsData = smsMessage[0].getUserData();
for(int index=0; index<smsData.length; ++index)
{
smsBody += Character.toString((char)smsData[index]);
}
}
that's it, pansit!
hi linus
ReplyDeletemy manifest file is:
-----------------------------------
------------------------------
but my demoApp dont receive any sms.
please guide me.
thanx
hi again
ReplyDeleteexcuse me,I do not know why the my code did not show up .
i use your code you mentioned.
What permissions do you have set؟
hi s.pahlavan, if you're receiving sms through a different port, you won't see it in your inbox like an ordinary sms. i use a toast in the onReceive() function to display what i receive.
ReplyDeletei have the following permisions set:
i believe you only need RECEIVE_SMS for this.