private void notifyMessageReceived(SmsMmsMessage message) {

    // Class 0 SMS, let the system handle this
    if (message.getMessageType() == SmsMmsMessage.MESSAGE_TYPE_SMS
        && message.getMessageClass() == MessageClass.CLASS_0) {
      return;
    }

    if (message.isSprintVisualVoicemail()) {
      return;
    }

    // Fetch preferences
    ManagePreferences mPrefs = new ManagePreferences(context, message.getContactId());

    // Whether or not the popup should only show when keyguard is on
    boolean onlyShowOnKeyguard =
        mPrefs.getBoolean(
            R.string.pref_onlyShowOnKeyguard_key, Defaults.PREFS_ONLY_SHOW_ON_KEYGUARD);

    // check if popup is enabled for this contact
    boolean showPopup =
        mPrefs.getBoolean(
            R.string.pref_popup_enabled_key,
            Defaults.PREFS_SHOW_POPUP,
            SmsPopupDbAdapter.KEY_POPUP_ENABLED_NUM);

    // check if notifications are on for this contact
    boolean notifEnabled =
        mPrefs.getBoolean(
            R.string.pref_notif_enabled_key,
            Defaults.PREFS_NOTIF_ENABLED,
            SmsPopupDbAdapter.KEY_ENABLED_NUM);

    // get docked state of phone
    int docked_state = mPrefs.getInt(R.string.pref_docked_key, 0);

    boolean docked = docked_state == ExternalEventReceiver.EXTRA_DOCK_STATE_DESK;

    mPrefs.close();

    // Fetch call state, if the user is in a call or the phone is ringing we don't want to show the
    // popup
    TelephonyManager mTM = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
    boolean callStateIdle = mTM.getCallState() == TelephonyManager.CALL_STATE_IDLE;

    // Init keyguard manager
    ManageKeyguard.initialize(context);

    /*
     * If popup is enabled for this user -AND- the user is not in a call -AND-
     * -AND- phone is not docked -AND-
     * (screen is locked -OR- (setting is OFF to only show on keyguard -AND- user is not in messaging app:
     * then show the popup activity, otherwise check if notifications are on and just use the standard
     * notification))
     */
    if (showPopup
        && callStateIdle
        && !docked
        && (ManageKeyguard.inKeyguardRestrictedInputMode()
            || (!onlyShowOnKeyguard && !SmsPopupUtils.inMessagingApp(context)))) {

      if (Log.DEBUG) Log.v("^^^^^^Showing SMS Popup");
      ManageWakeLock.acquireFull(context);
      context.startActivity(message.getPopupIntent());

    } else if (notifEnabled) {

      if (Log.DEBUG) Log.v("^^^^^^Not showing SMS Popup, using notifications");
      ManageNotification.show(context, message);
      ReminderReceiver.scheduleReminder(context, message);
    }
  }