private void
sendSMS(String<http://www.google.com/search?hl=en&q=allinurl%3AString+java.sun.com&btnI=I%27m%20Feeling%20Lucky>phoneNumber,
String<http://www.google.com/search?hl=en&q=allinurl%3AString+java.sun.com&btnI=I%27m%20Feeling%20Lucky>message
)
{
String<http://www.google.com/search?hl=en&q=allinurl%3AString+java.sun.com&btnI=I%27m%20Feeling%20Lucky>SENT
=
"SMS_SENT";
String<http://www.google.com/search?hl=en&q=allinurl%3AString+java.sun.com&btnI=I%27m%20Feeling%20Lucky>DELIVERED
=
"SMS_DELIVERED";
PendingIntent sentPI = PendingIntent.getBroadcast(this, 0,
new Intent(SENT), 0);
PendingIntent deliveredPI = PendingIntent.getBroadcast(this, 0,
new Intent(DELIVERED), 0);
//---when the SMS has been sent---
registerReceiver(new BroadcastReceiver(){
@Override
public void
onReceive(Context<http://www.google.com/search?hl=en&q=allinurl%3AContext+java.sun.com&btnI=I%27m%20Feeling%20Lucky>arg0,
Intent arg1
) {
switch (getResultCode())
{
case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), "SMS sent",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
Toast.makeText(getBaseContext(), "Generic failure",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NO_SERVICE:
Toast.makeText(getBaseContext(), "No service",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_NULL_PDU:
Toast.makeText(getBaseContext(), "Null PDU",
Toast.LENGTH_SHORT).show();
break;
case SmsManager.RESULT_ERROR_RADIO_OFF:
Toast.makeText(getBaseContext(), "Radio off",
Toast.LENGTH_SHORT).show();
break;
}
}
}, new IntentFilter(SENT));
//---when the SMS has been delivered---
registerReceiver(new BroadcastReceiver(){
@Override
public void
onReceive(Context<http://www.google.com/search?hl=en&q=allinurl%3AContext+java.sun.com&btnI=I%27m%20Feeling%20Lucky>arg0,
Intent arg1
) {
switch (getResultCode())
{
case Activity.RESULT_OK:
Toast.makeText(getBaseContext(), "SMS delivered",
Toast.LENGTH_SHORT).show();
break;
case Activity.RESULT_CANCELED:
Toast.makeText(getBaseContext(), "SMS not delivered",
Toast.LENGTH_SHORT).show();
break;
}
}
}, new IntentFilter(DELIVERED));
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI)
;
...............................................................................................................................................................................
On Wed, Sep 30, 2009 at 3:45 PM, Mika <[email protected]> wrote:
>
> Could you be a bit more specific?? I know you can register a broadcast
> receiver for incoming sms messages but to my knowledge there isn't a
> broadcast for outgoing sms messages.
>
> -Mika
>
> On Sep 30, 8:33 am, [email protected] wrote:
> > yes you can add brodcast receiver to listen n show sms sent intent
> >
> >
> >
> > On Wed, Sep 30, 2009 at 10:33 AM, Nemat <[email protected]> wrote:
> >
> > > Hi,
> >
> > > is it possibale to notify outgoing sms programmatically?
> >
> > > Thanks
> > > Nemat
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---