Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2014
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. private static final String ACTION_SENT = "sent";
  2.  
  3.  
  4. final Intent sentIntent = new Intent(ACTION_SENT);
  5. final PendingIntent sentPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, sentIntent,
  6.         PendingIntent.FLAG_UPDATE_CURRENT);
  7.  
  8. registerReceiver(new BroadcastReceiver() {
  9.     @Override
  10.     public void onReceive(Context context, Intent intent) {
  11.         String result = "";
  12.  
  13.         switch (getResultCode()) {
  14.         case Activity.RESULT_OK:
  15.             result = "Transmission successful";
  16.             break;
  17.         case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
  18.             result = "Transmission failed";
  19.             break;
  20.         case SmsManager.RESULT_ERROR_RADIO_OFF:
  21.             result = "Radio off";
  22.             break;
  23.         case SmsManager.RESULT_ERROR_NULL_PDU:
  24.             result = "No PDU defined";
  25.             break;
  26.         case SmsManager.RESULT_ERROR_NO_SERVICE:
  27.             result = "No service";
  28.             break;
  29.         }
  30.  
  31.         Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG).show();
  32.     }
  33. }, new IntentFilter(ACTION_SENT));
  34.  
  35.  
  36. smsManager.sendTextMessage("…", null, "…", sentPendingIntent, null);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement