http://mobiforge.com/developing/story/sms-messaging-android
I used the example code in the above link my own application for sending an SMS, but I run into a problem
First, you have a new BroadcastReceiver(){
every time you call sendSMS
, so they pile up, one more each time you call sendSMS
. You could add unregister(this);
at the bottom of each BroadcastReceiver
but better would be to move the Broadcast receiver out of this function. You can create+register one in onResume()
and unregister
it in onPause().
Second, read this link
if you ever want to send data along with your pendingIntent
you need to help Android distinguish your pending intents better ...
e.g.
PendingIntent deliveredPI = PendingIntent.getBroadcast(this, uniqueIdPerSMS++,
new Intent(DELIVERED), PendingIntent.FLAG_CANCEL_CURRENT);
The simple this is that use a unique id for each deliveredPI, because if you do not then android considers all the same and for all the sms's the deliveredPi will show the result of any one( do not know if first or last).