Back to project page smsgateway-android.
The source code is released under:
GNU General Public License
If you think the Android project smsgateway-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.nubgames.smsgateway; /*from w w w.j ava 2 s . co m*/ import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.telephony.gsm.SmsMessage; public class SMSReceiver extends BroadcastReceiver { private final static String ACTION = "android.provider.Telephony.SMS_RECEIVED"; @Override public void onReceive(Context context, Intent intent) { if(! intent.getAction().equals(ACTION)) { return; } // Log.d(SMSGateway.TAG, "SMSReceiver.onReceive"); Object[] pdus = (Object[]) intent.getExtras().get("pdus"); for (Object pdu : pdus) { SmsMessage msg = SmsMessage.createFromPdu((byte[]) pdu); Intent newIntent = new Intent(context, TextRouter.class); newIntent.putExtra("from", msg.getDisplayOriginatingAddress()); newIntent.putExtra("message", msg.getDisplayMessageBody()); context.startService(newIntent); } } }