I Could Not Get Data From Intent After Broadcast Received
I am writing a program that sends SMS message in Android. After a send button clicked, I want to get the status of the message like Sent, and delivered. This part works fine. The p
Solution 1:
Change your sendSMS
code into:
public void sendSMS(final String message, final String tele) {
String SENT = "SMS_SENT";
String DELIVERED = "SMS_DELIVERED";
SMSStatus sentStatus = new SMSStatus();
SMSDelivery deliveryStatus = new SMSDelivery();
//broadcast these during send and delivery
PendingIntent sentPI = PendingIntent.getBroadcast(SMS.this, 0, new Intent(SENT).putExtra("telephone", tele), PendingIntent.FLAG_UPDATE_CURRENT);
PendingIntent deliveredPI = PendingIntent.getBroadcast(SMS.this, 0, new Intent(DELIVERED).putExtra("telephone",tele), PendingIntent.FLAG_UPDATE_CURRENT);
registerReceiver(sentStatus, new IntentFilter(SENT));
registerReceiver(deliveryStatus, new IntentFilter(DELIVERED));
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(tele, null, message, sentPI, deliveredPI);
}
Post a Comment for "I Could Not Get Data From Intent After Broadcast Received"