Back to project page MySms.
The source code is released under:
Apache License
If you think the Android project MySms listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.henningta.mysms; // w ww . j a v a 2 s .c om import android.app.Activity; import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.telephony.SmsManager; import android.widget.Toast; public class SmsSentReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { WakeLocker.acquire(context); String source = intent.getStringExtra(Settings.KEY_SOURCE); String text = intent.getStringExtra(Settings.KEY_MESSAGE); long time = intent.getLongExtra(Settings.KEY_TIME, -1); if (source == null || text == null || time == -1) { return; } DatabaseHandler dbHandler = new DatabaseHandler(context); Message message = dbHandler.getMessage(source, text, time); switch (getResultCode()) { case Activity.RESULT_OK: //Toast.makeText(context, "SMS sent", Toast.LENGTH_SHORT).show(); message.setStatus(Message.STATUS_SENT); break; case SmsManager.RESULT_ERROR_GENERIC_FAILURE: Toast.makeText(context, "Generic failure", Toast.LENGTH_SHORT).show(); message.setStatus(Message.STATUS_FAILED); break; case SmsManager.RESULT_ERROR_NO_SERVICE: Toast.makeText(context, "No service", Toast.LENGTH_SHORT).show(); message.setStatus(Message.STATUS_FAILED); break; case SmsManager.RESULT_ERROR_NULL_PDU: Toast.makeText(context, "Null PDU", Toast.LENGTH_SHORT).show(); message.setStatus(Message.STATUS_FAILED); break; case SmsManager.RESULT_ERROR_RADIO_OFF: Toast.makeText(context, "Radio off", Toast.LENGTH_SHORT).show(); message.setStatus(Message.STATUS_FAILED); break; default: break; } // update message in database dbHandler.updateMessage(message); // refresh main page Intent conversationIntent = new Intent(Settings.ACTION_CONVERSATION); context.sendBroadcast(conversationIntent); // refresh messages page Intent refreshIntent = new Intent(Settings.ACTION_MESSAGE); refreshIntent.putExtra(Settings.KEY_REFRESH, true); context.sendBroadcast(refreshIntent); WakeLocker.release(); } }