Android Open Source - SMSTester S M S Error Status Receiver






From Project

Back to project page SMSTester.

License

The source code is released under:

GNU General Public License

If you think the Android project SMSTester listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

////////////////////////////////////////////////////////////////////
// SMSTester - https://lab.safermobile.org
// Copyright (c) 2011, SaferMobile / MobileActive
// See LICENSE for licensing information 
////  w  ww .ja v a 2  s  .  c  o m
// SMSErrorStatusReceiver: handles callbacks on error states that occur
// from sending messages, and logs these
//
////////////////////////////////////////////////////////////////////

package org.safermobile.sms;

import java.util.Date;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.telephony.SmsManager;

public class SMSErrorStatusReceiver extends BroadcastReceiver {

  private String _fromPhoneNumber;
  private String _toPhoneNumber;

  private SMSLogger _smsLogger;

  public SMSErrorStatusReceiver(String fromPhoneNumber, String toPhoneNumber,
      SMSLogger smsLogger) {
    _fromPhoneNumber = fromPhoneNumber;
    _toPhoneNumber = toPhoneNumber;

    _smsLogger = smsLogger;
  }

  @Override
  public void onReceive(Context context, Intent intent) {

    int resultCode = getResultCode();
    String resultTxt = "unknown error";

    Date ts = new Date();

    switch (resultCode) {
    case Activity.RESULT_OK:
      resultTxt = "sent";
      break;
    case SmsManager.RESULT_ERROR_GENERIC_FAILURE:
      resultTxt = "generic failure";
      break;
    case SmsManager.RESULT_ERROR_NO_SERVICE:
      resultTxt = "error no service";
      break;
    case SmsManager.RESULT_ERROR_NULL_PDU:
      resultTxt = "error null pdu";
      break;
    case SmsManager.RESULT_ERROR_RADIO_OFF:
      resultTxt = "radio off";
      break;
    }

    if (resultCode != Activity.RESULT_OK)
      _smsLogger.logError(_fromPhoneNumber, _toPhoneNumber, resultTxt, ts, "", "",
          "");

  }

}




Java Source Code List

org.safermobile.sms.EditKeywordActivity.java
org.safermobile.sms.LogViewActivity.java
org.safermobile.sms.MainTabActivity.java
org.safermobile.sms.SMSDataReceiver.java
org.safermobile.sms.SMSErrorStatusReceiver.java
org.safermobile.sms.SMSLogger.java
org.safermobile.sms.SMSReceiver.java
org.safermobile.sms.SMSSenderActivity.java
org.safermobile.sms.SMSTesterConstants.java
org.safermobile.sms.SettingsActivity.java
org.safermobile.sms.Utils.java