Code example for SmsMessage

Methods: getMessageClass, getOriginatingAddress

0
  private static final String SMS_RECEIVED_ACTION = "android.provider.Telephony.SMS_RECEIVED";
 
  private boolean isExemption(SmsMessage message, String messageBody) {
 
    // ignore CLASS0 ("flash") messages 
    if (message.getMessageClass() == SmsMessage.MessageClass.CLASS_0)
      return true; 
 
    // ignore OTP messages from Sparebank1 (Norwegian bank) 
    if (messageBody.startsWith("Sparebank1://otp?")) {
      return true; 
    } 
 
    // Sprint Visual Voicemail 
    return 
      message.getOriginatingAddress().length() < 7 &&
      (messageBody.startsWith("//ANDROID:") || messageBody.startsWith("//Android:") ||
       messageBody.startsWith("//android:") || messageBody.startsWith("//BREW:"));
  } 
 
  private SmsMessage getSmsMessageFromIntent(Intent intent) {