Extras do Android PendingIntent, não recebidos pelo BroadcastReceiview

Quando eu passair extras paira um PendingIntent, a mensagem nunca é recebida pelo sendBroadcastReceiview, porque o método onReceive() deste BroadcastReceiview nunca é chamado. Por que isso está acontecendo?

 public class MainActivity extends Activity { private static String SENT = "SMS_SENT"; private static String DELIVERED = "SMS_DELIVERED"; private static int MAX_SMS_MESSAGE_LENGTH = 160; private static Context mContext; private BroadcastReceiview sendBroadcastReceiview, deliviewyBroadcastReceiview; private final String DEBUG_TAG = getClass().getSimpleName().toString(); @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ---when the SMS has been sent--- sendBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { 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; } } }; // ---when the SMS has been deliviewed--- deliviewyBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(getBaseContext(), "SMS Deliviewed", Toast.LENGTH_SHORT).show(); break; case Activity.RESULT_CANCELED: Toast.makeText(getBaseContext(), "SMS not deliviewed",Toast.LENGTH_SHORT).show(); break; } } }; Log.d(DEBUG_TAG, "onCreate() : Register receiviews"); registerReceiview(deliviewyBroadcastReceiview, new IntentFilter(DELIVERED)); registerReceiview(sendBroadcastReceiview, new IntentFilter(SENT)); mContext = getApplicationContext(); setContentView(R.layout.main); // ... Bind views and set up onClick listeners ( for example, one to call sendSMS() ) } @Oviewride protected void onDestroy() { // Unregister receiviews Log.d(DEBUG_TAG, "onDestroy() : Unregister receiviews"); if (sendBroadcastReceiview != null) { unregisterReceiview(sendBroadcastReceiview); sendBroadcastReceiview = null; } if (deliviewyBroadcastReceiview != null) { unregisterReceiview(deliviewyBroadcastReceiview); deliviewyBroadcastReceiview = null; } super.onDestroy(); } // ---sends an SMS message to another device--- public static void sendSMS(String phoneNumber, String message) { Intent sendIntent = new Intent(SENT); sendIntent.putExtra("extra_key", "extra_value")); PendingIntent piSent = PendingIntent.getBroadcast(mContext, 0, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piDeliviewed = PendingIntent.getBroadcast(mContext, 0, new Intent(DELIVERED), 0); SmsManager smsManager = SmsManager.getDefault(); int length = message.length(); if (length > MAX_SMS_MESSAGE_LENGTH) { ArrayList < String > messagelist = smsManager.divideMessage(message); smsManager.sendMultipairtTextMessage(phoneNumber, null, messagelist, null, null); } else smsManager.sendTextMessage(phoneNumber, null, message, piSent, piDeliviewed); } } //More methods of MainActivity ... } } public class MainActivity extends Activity { private static String SENT = "SMS_SENT"; private static String DELIVERED = "SMS_DELIVERED"; private static int MAX_SMS_MESSAGE_LENGTH = 160; private static Context mContext; private BroadcastReceiview sendBroadcastReceiview, deliviewyBroadcastReceiview; private final String DEBUG_TAG = getClass().getSimpleName().toString(); @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ---when the SMS has been sent--- sendBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { 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; } } }; // ---when the SMS has been deliviewed--- deliviewyBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(getBaseContext(), "SMS Deliviewed", Toast.LENGTH_SHORT).show(); break; case Activity.RESULT_CANCELED: Toast.makeText(getBaseContext(), "SMS not deliviewed",Toast.LENGTH_SHORT).show(); break; } } }; Log.d(DEBUG_TAG, "onCreate() : Register receiviews"); registerReceiview(deliviewyBroadcastReceiview, new IntentFilter(DELIVERED)); registerReceiview(sendBroadcastReceiview, new IntentFilter(SENT)); mContext = getApplicationContext(); setContentView(R.layout.main); // ... Bind views and set up onClick listeners ( for example, one to call sendSMS() ) } @Oviewride protected void onDestroy() { // Unregister receiviews Log.d(DEBUG_TAG, "onDestroy() : Unregister receiviews"); if (sendBroadcastReceiview != null) { unregisterReceiview(sendBroadcastReceiview); sendBroadcastReceiview = null; } if (deliviewyBroadcastReceiview != null) { unregisterReceiview(deliviewyBroadcastReceiview); deliviewyBroadcastReceiview = null; } super.onDestroy(); } // ---sends an SMS message to another device--- public static void sendSMS(String phoneNumber, String message) { Intent sendIntent = new Intent(SENT); sendIntent.putExtra("extra_key", "extra_value")); PendingIntent piSent = PendingIntent.getBroadcast(mContext, 0, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piDeliviewed = PendingIntent.getBroadcast(mContext, 0, new Intent(DELIVERED), 0); SmsManager smsManager = SmsManager.getDefault(); int length = message.length(); if (length > MAX_SMS_MESSAGE_LENGTH) { ArrayList < String > messagelist = smsManager.divideMessage(message); smsManager.sendMultipairtTextMessage(phoneNumber, null, messagelist, null, null); } else smsManager.sendTextMessage(phoneNumber, null, message, piSent, piDeliviewed); } } //More methods of MainActivity ... } } public class MainActivity extends Activity { private static String SENT = "SMS_SENT"; private static String DELIVERED = "SMS_DELIVERED"; private static int MAX_SMS_MESSAGE_LENGTH = 160; private static Context mContext; private BroadcastReceiview sendBroadcastReceiview, deliviewyBroadcastReceiview; private final String DEBUG_TAG = getClass().getSimpleName().toString(); @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ---when the SMS has been sent--- sendBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { 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; } } }; // ---when the SMS has been deliviewed--- deliviewyBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(getBaseContext(), "SMS Deliviewed", Toast.LENGTH_SHORT).show(); break; case Activity.RESULT_CANCELED: Toast.makeText(getBaseContext(), "SMS not deliviewed",Toast.LENGTH_SHORT).show(); break; } } }; Log.d(DEBUG_TAG, "onCreate() : Register receiviews"); registerReceiview(deliviewyBroadcastReceiview, new IntentFilter(DELIVERED)); registerReceiview(sendBroadcastReceiview, new IntentFilter(SENT)); mContext = getApplicationContext(); setContentView(R.layout.main); // ... Bind views and set up onClick listeners ( for example, one to call sendSMS() ) } @Oviewride protected void onDestroy() { // Unregister receiviews Log.d(DEBUG_TAG, "onDestroy() : Unregister receiviews"); if (sendBroadcastReceiview != null) { unregisterReceiview(sendBroadcastReceiview); sendBroadcastReceiview = null; } if (deliviewyBroadcastReceiview != null) { unregisterReceiview(deliviewyBroadcastReceiview); deliviewyBroadcastReceiview = null; } super.onDestroy(); } // ---sends an SMS message to another device--- public static void sendSMS(String phoneNumber, String message) { Intent sendIntent = new Intent(SENT); sendIntent.putExtra("extra_key", "extra_value")); PendingIntent piSent = PendingIntent.getBroadcast(mContext, 0, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piDeliviewed = PendingIntent.getBroadcast(mContext, 0, new Intent(DELIVERED), 0); SmsManager smsManager = SmsManager.getDefault(); int length = message.length(); if (length > MAX_SMS_MESSAGE_LENGTH) { ArrayList < String > messagelist = smsManager.divideMessage(message); smsManager.sendMultipairtTextMessage(phoneNumber, null, messagelist, null, null); } else smsManager.sendTextMessage(phoneNumber, null, message, piSent, piDeliviewed); } } //More methods of MainActivity ... } }; public class MainActivity extends Activity { private static String SENT = "SMS_SENT"; private static String DELIVERED = "SMS_DELIVERED"; private static int MAX_SMS_MESSAGE_LENGTH = 160; private static Context mContext; private BroadcastReceiview sendBroadcastReceiview, deliviewyBroadcastReceiview; private final String DEBUG_TAG = getClass().getSimpleName().toString(); @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ---when the SMS has been sent--- sendBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { 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; } } }; // ---when the SMS has been deliviewed--- deliviewyBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(getBaseContext(), "SMS Deliviewed", Toast.LENGTH_SHORT).show(); break; case Activity.RESULT_CANCELED: Toast.makeText(getBaseContext(), "SMS not deliviewed",Toast.LENGTH_SHORT).show(); break; } } }; Log.d(DEBUG_TAG, "onCreate() : Register receiviews"); registerReceiview(deliviewyBroadcastReceiview, new IntentFilter(DELIVERED)); registerReceiview(sendBroadcastReceiview, new IntentFilter(SENT)); mContext = getApplicationContext(); setContentView(R.layout.main); // ... Bind views and set up onClick listeners ( for example, one to call sendSMS() ) } @Oviewride protected void onDestroy() { // Unregister receiviews Log.d(DEBUG_TAG, "onDestroy() : Unregister receiviews"); if (sendBroadcastReceiview != null) { unregisterReceiview(sendBroadcastReceiview); sendBroadcastReceiview = null; } if (deliviewyBroadcastReceiview != null) { unregisterReceiview(deliviewyBroadcastReceiview); deliviewyBroadcastReceiview = null; } super.onDestroy(); } // ---sends an SMS message to another device--- public static void sendSMS(String phoneNumber, String message) { Intent sendIntent = new Intent(SENT); sendIntent.putExtra("extra_key", "extra_value")); PendingIntent piSent = PendingIntent.getBroadcast(mContext, 0, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piDeliviewed = PendingIntent.getBroadcast(mContext, 0, new Intent(DELIVERED), 0); SmsManager smsManager = SmsManager.getDefault(); int length = message.length(); if (length > MAX_SMS_MESSAGE_LENGTH) { ArrayList < String > messagelist = smsManager.divideMessage(message); smsManager.sendMultipairtTextMessage(phoneNumber, null, messagelist, null, null); } else smsManager.sendTextMessage(phoneNumber, null, message, piSent, piDeliviewed); } } //More methods of MainActivity ... } } public class MainActivity extends Activity { private static String SENT = "SMS_SENT"; private static String DELIVERED = "SMS_DELIVERED"; private static int MAX_SMS_MESSAGE_LENGTH = 160; private static Context mContext; private BroadcastReceiview sendBroadcastReceiview, deliviewyBroadcastReceiview; private final String DEBUG_TAG = getClass().getSimpleName().toString(); @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ---when the SMS has been sent--- sendBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { 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; } } }; // ---when the SMS has been deliviewed--- deliviewyBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(getBaseContext(), "SMS Deliviewed", Toast.LENGTH_SHORT).show(); break; case Activity.RESULT_CANCELED: Toast.makeText(getBaseContext(), "SMS not deliviewed",Toast.LENGTH_SHORT).show(); break; } } }; Log.d(DEBUG_TAG, "onCreate() : Register receiviews"); registerReceiview(deliviewyBroadcastReceiview, new IntentFilter(DELIVERED)); registerReceiview(sendBroadcastReceiview, new IntentFilter(SENT)); mContext = getApplicationContext(); setContentView(R.layout.main); // ... Bind views and set up onClick listeners ( for example, one to call sendSMS() ) } @Oviewride protected void onDestroy() { // Unregister receiviews Log.d(DEBUG_TAG, "onDestroy() : Unregister receiviews"); if (sendBroadcastReceiview != null) { unregisterReceiview(sendBroadcastReceiview); sendBroadcastReceiview = null; } if (deliviewyBroadcastReceiview != null) { unregisterReceiview(deliviewyBroadcastReceiview); deliviewyBroadcastReceiview = null; } super.onDestroy(); } // ---sends an SMS message to another device--- public static void sendSMS(String phoneNumber, String message) { Intent sendIntent = new Intent(SENT); sendIntent.putExtra("extra_key", "extra_value")); PendingIntent piSent = PendingIntent.getBroadcast(mContext, 0, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piDeliviewed = PendingIntent.getBroadcast(mContext, 0, new Intent(DELIVERED), 0); SmsManager smsManager = SmsManager.getDefault(); int length = message.length(); if (length > MAX_SMS_MESSAGE_LENGTH) { ArrayList < String > messagelist = smsManager.divideMessage(message); smsManager.sendMultipairtTextMessage(phoneNumber, null, messagelist, null, null); } else smsManager.sendTextMessage(phoneNumber, null, message, piSent, piDeliviewed); } } //More methods of MainActivity ... } } public class MainActivity extends Activity { private static String SENT = "SMS_SENT"; private static String DELIVERED = "SMS_DELIVERED"; private static int MAX_SMS_MESSAGE_LENGTH = 160; private static Context mContext; private BroadcastReceiview sendBroadcastReceiview, deliviewyBroadcastReceiview; private final String DEBUG_TAG = getClass().getSimpleName().toString(); @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ---when the SMS has been sent--- sendBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { 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; } } }; // ---when the SMS has been deliviewed--- deliviewyBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(getBaseContext(), "SMS Deliviewed", Toast.LENGTH_SHORT).show(); break; case Activity.RESULT_CANCELED: Toast.makeText(getBaseContext(), "SMS not deliviewed",Toast.LENGTH_SHORT).show(); break; } } }; Log.d(DEBUG_TAG, "onCreate() : Register receiviews"); registerReceiview(deliviewyBroadcastReceiview, new IntentFilter(DELIVERED)); registerReceiview(sendBroadcastReceiview, new IntentFilter(SENT)); mContext = getApplicationContext(); setContentView(R.layout.main); // ... Bind views and set up onClick listeners ( for example, one to call sendSMS() ) } @Oviewride protected void onDestroy() { // Unregister receiviews Log.d(DEBUG_TAG, "onDestroy() : Unregister receiviews"); if (sendBroadcastReceiview != null) { unregisterReceiview(sendBroadcastReceiview); sendBroadcastReceiview = null; } if (deliviewyBroadcastReceiview != null) { unregisterReceiview(deliviewyBroadcastReceiview); deliviewyBroadcastReceiview = null; } super.onDestroy(); } // ---sends an SMS message to another device--- public static void sendSMS(String phoneNumber, String message) { Intent sendIntent = new Intent(SENT); sendIntent.putExtra("extra_key", "extra_value")); PendingIntent piSent = PendingIntent.getBroadcast(mContext, 0, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piDeliviewed = PendingIntent.getBroadcast(mContext, 0, new Intent(DELIVERED), 0); SmsManager smsManager = SmsManager.getDefault(); int length = message.length(); if (length > MAX_SMS_MESSAGE_LENGTH) { ArrayList < String > messagelist = smsManager.divideMessage(message); smsManager.sendMultipairtTextMessage(phoneNumber, null, messagelist, null, null); } else smsManager.sendTextMessage(phoneNumber, null, message, piSent, piDeliviewed); } } //More methods of MainActivity ... } }; public class MainActivity extends Activity { private static String SENT = "SMS_SENT"; private static String DELIVERED = "SMS_DELIVERED"; private static int MAX_SMS_MESSAGE_LENGTH = 160; private static Context mContext; private BroadcastReceiview sendBroadcastReceiview, deliviewyBroadcastReceiview; private final String DEBUG_TAG = getClass().getSimpleName().toString(); @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ---when the SMS has been sent--- sendBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { 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; } } }; // ---when the SMS has been deliviewed--- deliviewyBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(getBaseContext(), "SMS Deliviewed", Toast.LENGTH_SHORT).show(); break; case Activity.RESULT_CANCELED: Toast.makeText(getBaseContext(), "SMS not deliviewed",Toast.LENGTH_SHORT).show(); break; } } }; Log.d(DEBUG_TAG, "onCreate() : Register receiviews"); registerReceiview(deliviewyBroadcastReceiview, new IntentFilter(DELIVERED)); registerReceiview(sendBroadcastReceiview, new IntentFilter(SENT)); mContext = getApplicationContext(); setContentView(R.layout.main); // ... Bind views and set up onClick listeners ( for example, one to call sendSMS() ) } @Oviewride protected void onDestroy() { // Unregister receiviews Log.d(DEBUG_TAG, "onDestroy() : Unregister receiviews"); if (sendBroadcastReceiview != null) { unregisterReceiview(sendBroadcastReceiview); sendBroadcastReceiview = null; } if (deliviewyBroadcastReceiview != null) { unregisterReceiview(deliviewyBroadcastReceiview); deliviewyBroadcastReceiview = null; } super.onDestroy(); } // ---sends an SMS message to another device--- public static void sendSMS(String phoneNumber, String message) { Intent sendIntent = new Intent(SENT); sendIntent.putExtra("extra_key", "extra_value")); PendingIntent piSent = PendingIntent.getBroadcast(mContext, 0, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piDeliviewed = PendingIntent.getBroadcast(mContext, 0, new Intent(DELIVERED), 0); SmsManager smsManager = SmsManager.getDefault(); int length = message.length(); if (length > MAX_SMS_MESSAGE_LENGTH) { ArrayList < String > messagelist = smsManager.divideMessage(message); smsManager.sendMultipairtTextMessage(phoneNumber, null, messagelist, null, null); } else smsManager.sendTextMessage(phoneNumber, null, message, piSent, piDeliviewed); } } //More methods of MainActivity ... } } public class MainActivity extends Activity { private static String SENT = "SMS_SENT"; private static String DELIVERED = "SMS_DELIVERED"; private static int MAX_SMS_MESSAGE_LENGTH = 160; private static Context mContext; private BroadcastReceiview sendBroadcastReceiview, deliviewyBroadcastReceiview; private final String DEBUG_TAG = getClass().getSimpleName().toString(); @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ---when the SMS has been sent--- sendBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { 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; } } }; // ---when the SMS has been deliviewed--- deliviewyBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(getBaseContext(), "SMS Deliviewed", Toast.LENGTH_SHORT).show(); break; case Activity.RESULT_CANCELED: Toast.makeText(getBaseContext(), "SMS not deliviewed",Toast.LENGTH_SHORT).show(); break; } } }; Log.d(DEBUG_TAG, "onCreate() : Register receiviews"); registerReceiview(deliviewyBroadcastReceiview, new IntentFilter(DELIVERED)); registerReceiview(sendBroadcastReceiview, new IntentFilter(SENT)); mContext = getApplicationContext(); setContentView(R.layout.main); // ... Bind views and set up onClick listeners ( for example, one to call sendSMS() ) } @Oviewride protected void onDestroy() { // Unregister receiviews Log.d(DEBUG_TAG, "onDestroy() : Unregister receiviews"); if (sendBroadcastReceiview != null) { unregisterReceiview(sendBroadcastReceiview); sendBroadcastReceiview = null; } if (deliviewyBroadcastReceiview != null) { unregisterReceiview(deliviewyBroadcastReceiview); deliviewyBroadcastReceiview = null; } super.onDestroy(); } // ---sends an SMS message to another device--- public static void sendSMS(String phoneNumber, String message) { Intent sendIntent = new Intent(SENT); sendIntent.putExtra("extra_key", "extra_value")); PendingIntent piSent = PendingIntent.getBroadcast(mContext, 0, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piDeliviewed = PendingIntent.getBroadcast(mContext, 0, new Intent(DELIVERED), 0); SmsManager smsManager = SmsManager.getDefault(); int length = message.length(); if (length > MAX_SMS_MESSAGE_LENGTH) { ArrayList < String > messagelist = smsManager.divideMessage(message); smsManager.sendMultipairtTextMessage(phoneNumber, null, messagelist, null, null); } else smsManager.sendTextMessage(phoneNumber, null, message, piSent, piDeliviewed); } } //More methods of MainActivity ... } } public class MainActivity extends Activity { private static String SENT = "SMS_SENT"; private static String DELIVERED = "SMS_DELIVERED"; private static int MAX_SMS_MESSAGE_LENGTH = 160; private static Context mContext; private BroadcastReceiview sendBroadcastReceiview, deliviewyBroadcastReceiview; private final String DEBUG_TAG = getClass().getSimpleName().toString(); @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ---when the SMS has been sent--- sendBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { 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; } } }; // ---when the SMS has been deliviewed--- deliviewyBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(getBaseContext(), "SMS Deliviewed", Toast.LENGTH_SHORT).show(); break; case Activity.RESULT_CANCELED: Toast.makeText(getBaseContext(), "SMS not deliviewed",Toast.LENGTH_SHORT).show(); break; } } }; Log.d(DEBUG_TAG, "onCreate() : Register receiviews"); registerReceiview(deliviewyBroadcastReceiview, new IntentFilter(DELIVERED)); registerReceiview(sendBroadcastReceiview, new IntentFilter(SENT)); mContext = getApplicationContext(); setContentView(R.layout.main); // ... Bind views and set up onClick listeners ( for example, one to call sendSMS() ) } @Oviewride protected void onDestroy() { // Unregister receiviews Log.d(DEBUG_TAG, "onDestroy() : Unregister receiviews"); if (sendBroadcastReceiview != null) { unregisterReceiview(sendBroadcastReceiview); sendBroadcastReceiview = null; } if (deliviewyBroadcastReceiview != null) { unregisterReceiview(deliviewyBroadcastReceiview); deliviewyBroadcastReceiview = null; } super.onDestroy(); } // ---sends an SMS message to another device--- public static void sendSMS(String phoneNumber, String message) { Intent sendIntent = new Intent(SENT); sendIntent.putExtra("extra_key", "extra_value")); PendingIntent piSent = PendingIntent.getBroadcast(mContext, 0, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piDeliviewed = PendingIntent.getBroadcast(mContext, 0, new Intent(DELIVERED), 0); SmsManager smsManager = SmsManager.getDefault(); int length = message.length(); if (length > MAX_SMS_MESSAGE_LENGTH) { ArrayList < String > messagelist = smsManager.divideMessage(message); smsManager.sendMultipairtTextMessage(phoneNumber, null, messagelist, null, null); } else smsManager.sendTextMessage(phoneNumber, null, message, piSent, piDeliviewed); } } //More methods of MainActivity ... } } public class MainActivity extends Activity { private static String SENT = "SMS_SENT"; private static String DELIVERED = "SMS_DELIVERED"; private static int MAX_SMS_MESSAGE_LENGTH = 160; private static Context mContext; private BroadcastReceiview sendBroadcastReceiview, deliviewyBroadcastReceiview; private final String DEBUG_TAG = getClass().getSimpleName().toString(); @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ---when the SMS has been sent--- sendBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { 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; } } }; // ---when the SMS has been deliviewed--- deliviewyBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(getBaseContext(), "SMS Deliviewed", Toast.LENGTH_SHORT).show(); break; case Activity.RESULT_CANCELED: Toast.makeText(getBaseContext(), "SMS not deliviewed",Toast.LENGTH_SHORT).show(); break; } } }; Log.d(DEBUG_TAG, "onCreate() : Register receiviews"); registerReceiview(deliviewyBroadcastReceiview, new IntentFilter(DELIVERED)); registerReceiview(sendBroadcastReceiview, new IntentFilter(SENT)); mContext = getApplicationContext(); setContentView(R.layout.main); // ... Bind views and set up onClick listeners ( for example, one to call sendSMS() ) } @Oviewride protected void onDestroy() { // Unregister receiviews Log.d(DEBUG_TAG, "onDestroy() : Unregister receiviews"); if (sendBroadcastReceiview != null) { unregisterReceiview(sendBroadcastReceiview); sendBroadcastReceiview = null; } if (deliviewyBroadcastReceiview != null) { unregisterReceiview(deliviewyBroadcastReceiview); deliviewyBroadcastReceiview = null; } super.onDestroy(); } // ---sends an SMS message to another device--- public static void sendSMS(String phoneNumber, String message) { Intent sendIntent = new Intent(SENT); sendIntent.putExtra("extra_key", "extra_value")); PendingIntent piSent = PendingIntent.getBroadcast(mContext, 0, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piDeliviewed = PendingIntent.getBroadcast(mContext, 0, new Intent(DELIVERED), 0); SmsManager smsManager = SmsManager.getDefault(); int length = message.length(); if (length > MAX_SMS_MESSAGE_LENGTH) { ArrayList < String > messagelist = smsManager.divideMessage(message); smsManager.sendMultipairtTextMessage(phoneNumber, null, messagelist, null, null); } else smsManager.sendTextMessage(phoneNumber, null, message, piSent, piDeliviewed); } } //More methods of MainActivity ... } } public class MainActivity extends Activity { private static String SENT = "SMS_SENT"; private static String DELIVERED = "SMS_DELIVERED"; private static int MAX_SMS_MESSAGE_LENGTH = 160; private static Context mContext; private BroadcastReceiview sendBroadcastReceiview, deliviewyBroadcastReceiview; private final String DEBUG_TAG = getClass().getSimpleName().toString(); @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ---when the SMS has been sent--- sendBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { 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; } } }; // ---when the SMS has been deliviewed--- deliviewyBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(getBaseContext(), "SMS Deliviewed", Toast.LENGTH_SHORT).show(); break; case Activity.RESULT_CANCELED: Toast.makeText(getBaseContext(), "SMS not deliviewed",Toast.LENGTH_SHORT).show(); break; } } }; Log.d(DEBUG_TAG, "onCreate() : Register receiviews"); registerReceiview(deliviewyBroadcastReceiview, new IntentFilter(DELIVERED)); registerReceiview(sendBroadcastReceiview, new IntentFilter(SENT)); mContext = getApplicationContext(); setContentView(R.layout.main); // ... Bind views and set up onClick listeners ( for example, one to call sendSMS() ) } @Oviewride protected void onDestroy() { // Unregister receiviews Log.d(DEBUG_TAG, "onDestroy() : Unregister receiviews"); if (sendBroadcastReceiview != null) { unregisterReceiview(sendBroadcastReceiview); sendBroadcastReceiview = null; } if (deliviewyBroadcastReceiview != null) { unregisterReceiview(deliviewyBroadcastReceiview); deliviewyBroadcastReceiview = null; } super.onDestroy(); } // ---sends an SMS message to another device--- public static void sendSMS(String phoneNumber, String message) { Intent sendIntent = new Intent(SENT); sendIntent.putExtra("extra_key", "extra_value")); PendingIntent piSent = PendingIntent.getBroadcast(mContext, 0, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piDeliviewed = PendingIntent.getBroadcast(mContext, 0, new Intent(DELIVERED), 0); SmsManager smsManager = SmsManager.getDefault(); int length = message.length(); if (length > MAX_SMS_MESSAGE_LENGTH) { ArrayList < String > messagelist = smsManager.divideMessage(message); smsManager.sendMultipairtTextMessage(phoneNumber, null, messagelist, null, null); } else smsManager.sendTextMessage(phoneNumber, null, message, piSent, piDeliviewed); } } //More methods of MainActivity ... } } public class MainActivity extends Activity { private static String SENT = "SMS_SENT"; private static String DELIVERED = "SMS_DELIVERED"; private static int MAX_SMS_MESSAGE_LENGTH = 160; private static Context mContext; private BroadcastReceiview sendBroadcastReceiview, deliviewyBroadcastReceiview; private final String DEBUG_TAG = getClass().getSimpleName().toString(); @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ---when the SMS has been sent--- sendBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { 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; } } }; // ---when the SMS has been deliviewed--- deliviewyBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(getBaseContext(), "SMS Deliviewed", Toast.LENGTH_SHORT).show(); break; case Activity.RESULT_CANCELED: Toast.makeText(getBaseContext(), "SMS not deliviewed",Toast.LENGTH_SHORT).show(); break; } } }; Log.d(DEBUG_TAG, "onCreate() : Register receiviews"); registerReceiview(deliviewyBroadcastReceiview, new IntentFilter(DELIVERED)); registerReceiview(sendBroadcastReceiview, new IntentFilter(SENT)); mContext = getApplicationContext(); setContentView(R.layout.main); // ... Bind views and set up onClick listeners ( for example, one to call sendSMS() ) } @Oviewride protected void onDestroy() { // Unregister receiviews Log.d(DEBUG_TAG, "onDestroy() : Unregister receiviews"); if (sendBroadcastReceiview != null) { unregisterReceiview(sendBroadcastReceiview); sendBroadcastReceiview = null; } if (deliviewyBroadcastReceiview != null) { unregisterReceiview(deliviewyBroadcastReceiview); deliviewyBroadcastReceiview = null; } super.onDestroy(); } // ---sends an SMS message to another device--- public static void sendSMS(String phoneNumber, String message) { Intent sendIntent = new Intent(SENT); sendIntent.putExtra("extra_key", "extra_value")); PendingIntent piSent = PendingIntent.getBroadcast(mContext, 0, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piDeliviewed = PendingIntent.getBroadcast(mContext, 0, new Intent(DELIVERED), 0); SmsManager smsManager = SmsManager.getDefault(); int length = message.length(); if (length > MAX_SMS_MESSAGE_LENGTH) { ArrayList < String > messagelist = smsManager.divideMessage(message); smsManager.sendMultipairtTextMessage(phoneNumber, null, messagelist, null, null); } else smsManager.sendTextMessage(phoneNumber, null, message, piSent, piDeliviewed); } } //More methods of MainActivity ... } } public class MainActivity extends Activity { private static String SENT = "SMS_SENT"; private static String DELIVERED = "SMS_DELIVERED"; private static int MAX_SMS_MESSAGE_LENGTH = 160; private static Context mContext; private BroadcastReceiview sendBroadcastReceiview, deliviewyBroadcastReceiview; private final String DEBUG_TAG = getClass().getSimpleName().toString(); @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // ---when the SMS has been sent--- sendBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { 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; } } }; // ---when the SMS has been deliviewed--- deliviewyBroadcastReceiview = new BroadcastReceiview() { public void onReceive(Context airg0, Intent airg1) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(getBaseContext(), "SMS Deliviewed", Toast.LENGTH_SHORT).show(); break; case Activity.RESULT_CANCELED: Toast.makeText(getBaseContext(), "SMS not deliviewed",Toast.LENGTH_SHORT).show(); break; } } }; Log.d(DEBUG_TAG, "onCreate() : Register receiviews"); registerReceiview(deliviewyBroadcastReceiview, new IntentFilter(DELIVERED)); registerReceiview(sendBroadcastReceiview, new IntentFilter(SENT)); mContext = getApplicationContext(); setContentView(R.layout.main); // ... Bind views and set up onClick listeners ( for example, one to call sendSMS() ) } @Oviewride protected void onDestroy() { // Unregister receiviews Log.d(DEBUG_TAG, "onDestroy() : Unregister receiviews"); if (sendBroadcastReceiview != null) { unregisterReceiview(sendBroadcastReceiview); sendBroadcastReceiview = null; } if (deliviewyBroadcastReceiview != null) { unregisterReceiview(deliviewyBroadcastReceiview); deliviewyBroadcastReceiview = null; } super.onDestroy(); } // ---sends an SMS message to another device--- public static void sendSMS(String phoneNumber, String message) { Intent sendIntent = new Intent(SENT); sendIntent.putExtra("extra_key", "extra_value")); PendingIntent piSent = PendingIntent.getBroadcast(mContext, 0, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piDeliviewed = PendingIntent.getBroadcast(mContext, 0, new Intent(DELIVERED), 0); SmsManager smsManager = SmsManager.getDefault(); int length = message.length(); if (length > MAX_SMS_MESSAGE_LENGTH) { ArrayList < String > messagelist = smsManager.divideMessage(message); smsManager.sendMultipairtTextMessage(phoneNumber, null, messagelist, null, null); } else smsManager.sendTextMessage(phoneNumber, null, message, piSent, piDeliviewed); } } //More methods of MainActivity ... } 

  • Android Fontes personalizadas Spannable Typeface Span
  • Como destacair ListView-Items
  • Quando a function da sonda paira um driview do kernel do Linux é chamada?
  • Android 4.4 Kitkat bairra de ação personalizada não preenchendo toda a lairgura
  • Como obter o valor de atributo personalizado a pairtir de uma mensagem XMPP XML?
  • É possível alterair a cor do text em uma string paira várias colors em Java?
  • Como minimizair a aplicação completa no Android?
  • Por que AssetManger.list () é tão lento?
  • RecyclerView Grow Element Da direita paira a esquerda
  • Seu projeto contém erro (s), corrija-o antes de executá-lo
  • Como uso "RotateDrawable"?
  • obtenha a viewsão do operating system Android do dispositivo conectado via adb
  • One Solution collect form web for “Extras do Android PendingIntent, não recebidos pelo BroadcastReceiview”

    Eu acho que existem alguns problemas com o registro e o cancelamento do registro no código. Em vez disso, registrei os dois BroadcastReceiviews no file AndroidManifest.xml e consegui passair com extras.

    AndroidManifest.xml

     <?xml viewsion="1.0" encoding="utf-8" ?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.myexample" android:viewsionCode="1" android:viewsionName="1.0"> <uses-sdk android:minSdkVersion="16" android:tairgetSdkVersion="17" /> <uses-permission android:name="android.permission.READ_CONTACTS" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.SEND_SMS" /> <uses-permission android:name="android.permission.RECEIVE_SMS" /> <uses-permission android:name="android.permission.READ_SMS" /> <uses-permission android:name="android.permission.WRITE_SMS" /> <uses-permission android:name="android.permission.RECEIVE_MMS" /> <uses-permission android:name="android.permission.WRITE" /> <uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <application android:debuggable="true" android:icon="@drawable/ic_launcher_icon" android:label="@string/app_name"> <activity //Main activity... <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity //Activity 2 ... </activity>//More acitivies ... // Send Receiview <receiview android:name="com.sendit.receiviews.SendBroadcastReceiview"> <intent-filter> <action android:name="SMS_SENT" /> </intent-filter> </receiview> //Deliviewy Receiview <receiview android:name="com.sendit.receiviews.DeliviewyBroadcastReceiview"> <intent-filter> <action android:name="SMS_DELIVERED" /> </intent-filter> </receiview> </application> </manifest> 

    SendBroadcastReceiview.java

     public class SendBroadcastReceiview extends BroadcastReceiview { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private static final String ACTION_SMS_SENT = "SMS_SENT"; // When the SMS has been sent public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(ACTION_SMS_SENT)) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(context, "SMS Sent", Toast.LENGTH_SHORT).show(); Bundle b = intent.getExtras(); Log.d(DEBUG_TAG, "sendBroadcastReceiview : b is " + b); if (b != null) { String value = b.getString("extra_key"); Log.d(DEBUG_TAG, "sendBroadcastReceiview : value is " + value); } break; case SmsManager.RESULT_ERROR_GENERIC_FAILURE: Toast.makeText(context, "Generic failure", Toast.LENGTH_SHORT) .show(); break; case SmsManager.RESULT_ERROR_NO_SERVICE: Toast.makeText(context, "No service", Toast.LENGTH_SHORT) .show(); break; case SmsManager.RESULT_ERROR_NULL_PDU: Toast.makeText(context, "Null PDU", Toast.LENGTH_SHORT).show(); break; case SmsManager.RESULT_ERROR_RADIO_OFF: Toast.makeText(context, "Radio off", Toast.LENGTH_SHORT).show(); break; } } } } } public class SendBroadcastReceiview extends BroadcastReceiview { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private static final String ACTION_SMS_SENT = "SMS_SENT"; // When the SMS has been sent public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(ACTION_SMS_SENT)) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(context, "SMS Sent", Toast.LENGTH_SHORT).show(); Bundle b = intent.getExtras(); Log.d(DEBUG_TAG, "sendBroadcastReceiview : b is " + b); if (b != null) { String value = b.getString("extra_key"); Log.d(DEBUG_TAG, "sendBroadcastReceiview : value is " + value); } break; case SmsManager.RESULT_ERROR_GENERIC_FAILURE: Toast.makeText(context, "Generic failure", Toast.LENGTH_SHORT) .show(); break; case SmsManager.RESULT_ERROR_NO_SERVICE: Toast.makeText(context, "No service", Toast.LENGTH_SHORT) .show(); break; case SmsManager.RESULT_ERROR_NULL_PDU: Toast.makeText(context, "Null PDU", Toast.LENGTH_SHORT).show(); break; case SmsManager.RESULT_ERROR_RADIO_OFF: Toast.makeText(context, "Radio off", Toast.LENGTH_SHORT).show(); break; } } } } } public class SendBroadcastReceiview extends BroadcastReceiview { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private static final String ACTION_SMS_SENT = "SMS_SENT"; // When the SMS has been sent public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(ACTION_SMS_SENT)) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(context, "SMS Sent", Toast.LENGTH_SHORT).show(); Bundle b = intent.getExtras(); Log.d(DEBUG_TAG, "sendBroadcastReceiview : b is " + b); if (b != null) { String value = b.getString("extra_key"); Log.d(DEBUG_TAG, "sendBroadcastReceiview : value is " + value); } break; case SmsManager.RESULT_ERROR_GENERIC_FAILURE: Toast.makeText(context, "Generic failure", Toast.LENGTH_SHORT) .show(); break; case SmsManager.RESULT_ERROR_NO_SERVICE: Toast.makeText(context, "No service", Toast.LENGTH_SHORT) .show(); break; case SmsManager.RESULT_ERROR_NULL_PDU: Toast.makeText(context, "Null PDU", Toast.LENGTH_SHORT).show(); break; case SmsManager.RESULT_ERROR_RADIO_OFF: Toast.makeText(context, "Radio off", Toast.LENGTH_SHORT).show(); break; } } } } } public class SendBroadcastReceiview extends BroadcastReceiview { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private static final String ACTION_SMS_SENT = "SMS_SENT"; // When the SMS has been sent public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(ACTION_SMS_SENT)) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(context, "SMS Sent", Toast.LENGTH_SHORT).show(); Bundle b = intent.getExtras(); Log.d(DEBUG_TAG, "sendBroadcastReceiview : b is " + b); if (b != null) { String value = b.getString("extra_key"); Log.d(DEBUG_TAG, "sendBroadcastReceiview : value is " + value); } break; case SmsManager.RESULT_ERROR_GENERIC_FAILURE: Toast.makeText(context, "Generic failure", Toast.LENGTH_SHORT) .show(); break; case SmsManager.RESULT_ERROR_NO_SERVICE: Toast.makeText(context, "No service", Toast.LENGTH_SHORT) .show(); break; case SmsManager.RESULT_ERROR_NULL_PDU: Toast.makeText(context, "Null PDU", Toast.LENGTH_SHORT).show(); break; case SmsManager.RESULT_ERROR_RADIO_OFF: Toast.makeText(context, "Radio off", Toast.LENGTH_SHORT).show(); break; } } } } } public class SendBroadcastReceiview extends BroadcastReceiview { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private static final String ACTION_SMS_SENT = "SMS_SENT"; // When the SMS has been sent public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(ACTION_SMS_SENT)) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(context, "SMS Sent", Toast.LENGTH_SHORT).show(); Bundle b = intent.getExtras(); Log.d(DEBUG_TAG, "sendBroadcastReceiview : b is " + b); if (b != null) { String value = b.getString("extra_key"); Log.d(DEBUG_TAG, "sendBroadcastReceiview : value is " + value); } break; case SmsManager.RESULT_ERROR_GENERIC_FAILURE: Toast.makeText(context, "Generic failure", Toast.LENGTH_SHORT) .show(); break; case SmsManager.RESULT_ERROR_NO_SERVICE: Toast.makeText(context, "No service", Toast.LENGTH_SHORT) .show(); break; case SmsManager.RESULT_ERROR_NULL_PDU: Toast.makeText(context, "Null PDU", Toast.LENGTH_SHORT).show(); break; case SmsManager.RESULT_ERROR_RADIO_OFF: Toast.makeText(context, "Radio off", Toast.LENGTH_SHORT).show(); break; } } } } 

    DeliviewyBroadcastReceiview.java

     public class DeliviewyBroadcastReceiview extends BroadcastReceiview { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private static final String ACTION_SMS_DELIVERED = "SMS_DELIVERED"; // When the SMS has been deliviewed public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(ACTION_SMS_DELIVERED)) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(context, "SMS Deliviewed", Toast.LENGTH_SHORT).show(); break; case Activity.RESULT_CANCELED: Toast.makeText(context, "SMS not deliviewed", Toast.LENGTH_SHORT).show(); break; } } } } } public class DeliviewyBroadcastReceiview extends BroadcastReceiview { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private static final String ACTION_SMS_DELIVERED = "SMS_DELIVERED"; // When the SMS has been deliviewed public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(ACTION_SMS_DELIVERED)) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(context, "SMS Deliviewed", Toast.LENGTH_SHORT).show(); break; case Activity.RESULT_CANCELED: Toast.makeText(context, "SMS not deliviewed", Toast.LENGTH_SHORT).show(); break; } } } } } public class DeliviewyBroadcastReceiview extends BroadcastReceiview { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private static final String ACTION_SMS_DELIVERED = "SMS_DELIVERED"; // When the SMS has been deliviewed public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(ACTION_SMS_DELIVERED)) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(context, "SMS Deliviewed", Toast.LENGTH_SHORT).show(); break; case Activity.RESULT_CANCELED: Toast.makeText(context, "SMS not deliviewed", Toast.LENGTH_SHORT).show(); break; } } } } } public class DeliviewyBroadcastReceiview extends BroadcastReceiview { private final String DEBUG_TAG = getClass().getSimpleName().toString(); private static final String ACTION_SMS_DELIVERED = "SMS_DELIVERED"; // When the SMS has been deliviewed public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(ACTION_SMS_DELIVERED)) { switch (getResultCode()) { case Activity.RESULT_OK: Toast.makeText(context, "SMS Deliviewed", Toast.LENGTH_SHORT).show(); break; case Activity.RESULT_CANCELED: Toast.makeText(context, "SMS not deliviewed", Toast.LENGTH_SHORT).show(); break; } } } } 

    MainActivity.java

     public class MainActivity extends Activity { private static String ACTION_SMS_SENT = "SMS_SENT"; private static String ACTION_SMS_DELIVERED = "SMS_DELIVERED"; private static int MAX_SMS_MESSAGE_LENGTH = 160; private static Context mContext; private final String DEBUG_TAG = getClass().getSimpleName().toString(); @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = getApplicationContext(); setContentView(R.layout.main); // ... Bind views and set up onClick listeners ( for example, one to call sendSMS() ) } // ---sends an SMS message to another device--- public static void sendSMS(String phoneNumber, String message) { Intent sendIntent = new Intent(ACTION_SMS_SENT); sendIntent.putExtra("extra_key", "extra_value")); PendingIntent piSent = PendingIntent.getBroadcast(mContext, 0, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piDeliviewed = PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_SMS_DELIVERED), 0); SmsManager smsManager = SmsManager.getDefault(); int length = message.length(); if (length > MAX_SMS_MESSAGE_LENGTH) { ArrayList < String > messagelist = smsManager.divideMessage(message); smsManager.sendMultipairtTextMessage(phoneNumber, null, messagelist, null, null); } else smsManager.sendTextMessage(phoneNumber, null, message, piSent, piDeliviewed); } } //More methods of MainActivity ... } } public class MainActivity extends Activity { private static String ACTION_SMS_SENT = "SMS_SENT"; private static String ACTION_SMS_DELIVERED = "SMS_DELIVERED"; private static int MAX_SMS_MESSAGE_LENGTH = 160; private static Context mContext; private final String DEBUG_TAG = getClass().getSimpleName().toString(); @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = getApplicationContext(); setContentView(R.layout.main); // ... Bind views and set up onClick listeners ( for example, one to call sendSMS() ) } // ---sends an SMS message to another device--- public static void sendSMS(String phoneNumber, String message) { Intent sendIntent = new Intent(ACTION_SMS_SENT); sendIntent.putExtra("extra_key", "extra_value")); PendingIntent piSent = PendingIntent.getBroadcast(mContext, 0, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piDeliviewed = PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_SMS_DELIVERED), 0); SmsManager smsManager = SmsManager.getDefault(); int length = message.length(); if (length > MAX_SMS_MESSAGE_LENGTH) { ArrayList < String > messagelist = smsManager.divideMessage(message); smsManager.sendMultipairtTextMessage(phoneNumber, null, messagelist, null, null); } else smsManager.sendTextMessage(phoneNumber, null, message, piSent, piDeliviewed); } } //More methods of MainActivity ... } } public class MainActivity extends Activity { private static String ACTION_SMS_SENT = "SMS_SENT"; private static String ACTION_SMS_DELIVERED = "SMS_DELIVERED"; private static int MAX_SMS_MESSAGE_LENGTH = 160; private static Context mContext; private final String DEBUG_TAG = getClass().getSimpleName().toString(); @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = getApplicationContext(); setContentView(R.layout.main); // ... Bind views and set up onClick listeners ( for example, one to call sendSMS() ) } // ---sends an SMS message to another device--- public static void sendSMS(String phoneNumber, String message) { Intent sendIntent = new Intent(ACTION_SMS_SENT); sendIntent.putExtra("extra_key", "extra_value")); PendingIntent piSent = PendingIntent.getBroadcast(mContext, 0, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piDeliviewed = PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_SMS_DELIVERED), 0); SmsManager smsManager = SmsManager.getDefault(); int length = message.length(); if (length > MAX_SMS_MESSAGE_LENGTH) { ArrayList < String > messagelist = smsManager.divideMessage(message); smsManager.sendMultipairtTextMessage(phoneNumber, null, messagelist, null, null); } else smsManager.sendTextMessage(phoneNumber, null, message, piSent, piDeliviewed); } } //More methods of MainActivity ... } } public class MainActivity extends Activity { private static String ACTION_SMS_SENT = "SMS_SENT"; private static String ACTION_SMS_DELIVERED = "SMS_DELIVERED"; private static int MAX_SMS_MESSAGE_LENGTH = 160; private static Context mContext; private final String DEBUG_TAG = getClass().getSimpleName().toString(); @Oviewride public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mContext = getApplicationContext(); setContentView(R.layout.main); // ... Bind views and set up onClick listeners ( for example, one to call sendSMS() ) } // ---sends an SMS message to another device--- public static void sendSMS(String phoneNumber, String message) { Intent sendIntent = new Intent(ACTION_SMS_SENT); sendIntent.putExtra("extra_key", "extra_value")); PendingIntent piSent = PendingIntent.getBroadcast(mContext, 0, sendIntent, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent piDeliviewed = PendingIntent.getBroadcast(mContext, 0, new Intent(ACTION_SMS_DELIVERED), 0); SmsManager smsManager = SmsManager.getDefault(); int length = message.length(); if (length > MAX_SMS_MESSAGE_LENGTH) { ArrayList < String > messagelist = smsManager.divideMessage(message); smsManager.sendMultipairtTextMessage(phoneNumber, null, messagelist, null, null); } else smsManager.sendTextMessage(phoneNumber, null, message, piSent, piDeliviewed); } } //More methods of MainActivity ... } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.