Sending an SMS in background is quite simple. below is the code that will let one do that
public void sendSMS(String message,String destination)
Note that there are two receivers one is SMSSentStatusReceiver and SMSDeliveryStatusReceiver which will receive the callbacks to update the status of sent and delivery respectively.
References:
public void sendSMS(String message,String destination)
{
SmsManager smsManager = SmsManager.getDefault();
if( smsManager != null )
{
PendingIntent sentPI = PendingIntent.getBroadcast(AppUtils.getAppContext(), 0,
new Intent(AppUtils.getAppContext(), SMSSentStatusReceiver.class), 0);
PendingIntent deliveredPI = PendingIntent.getBroadcast(AppUtils.getAppContext(), 0,
new Intent(AppUtils.getAppContext(), SMSDeliveryStatusReceiver.class), 0);
smsManager.sendTextMessage(destination,null,message,sentPI,deliveredPI);
}
}
Note that there are two receivers one is SMSSentStatusReceiver and SMSDeliveryStatusReceiver which will receive the callbacks to update the status of sent and delivery respectively.
References:
No comments:
Post a Comment