Code example for SmsMessage

Methods: getMessageClassgetOriginatingAddress

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; 
    } 
 
    return 
      message.getOriginatingAddress().length() < 7 &&
      (messageBody.toUpperCase().startsWith("//ANDROID:") || // Sprint Visual Voicemail
       messageBody.startsWith("//BREW:")); //BREW stands for “Binary Runtime Environment for Wireless"
  } 
 
  private SmsMessage getSmsMessageFromIntent(Intent intent) {