Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static final String ACTION_SENT = "sent";
- …
- final Intent sentIntent = new Intent(ACTION_SENT);
- final PendingIntent sentPendingIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, sentIntent,
- PendingIntent.FLAG_UPDATE_CURRENT);
- registerReceiver(new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- String result = "";
- switch (getResultCode()) {
- case Activity.RESULT_OK:
- result = "Transmission successful";
- break;
- case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
- result = "Transmission failed";
- break;
- case SmsManager.RESULT_ERROR_RADIO_OFF:
- result = "Radio off";
- break;
- case SmsManager.RESULT_ERROR_NULL_PDU:
- result = "No PDU defined";
- break;
- case SmsManager.RESULT_ERROR_NO_SERVICE:
- result = "No service";
- break;
- }
- Toast.makeText(getApplicationContext(), result, Toast.LENGTH_LONG).show();
- }
- }, new IntentFilter(ACTION_SENT));
- …
- smsManager.sendTextMessage("…", null, "…", sentPendingIntent, null);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement