Пример #1
0
 @Override
 public void onFragmentDestroy() {
     super.onFragmentDestroy();
     NotificationCenter.Instance.removeObserver(this, MessagesController.mediaDidLoaded);
     NotificationCenter.Instance.removeObserver(this, MessagesController.didReceivedNewMessages);
     NotificationCenter.Instance.removeObserver(this, MessagesController.messagesDeleted);
     NotificationCenter.Instance.removeObserver(this, MessagesController.messageReceivedByServer);
 }
Пример #2
0
 @Override
 public boolean onFragmentCreate() {
     super.onFragmentCreate();
     NotificationCenter.Instance.addObserver(this, MessagesController.mediaDidLoaded);
     NotificationCenter.Instance.addObserver(this, MessagesController.messagesDeleted);
     NotificationCenter.Instance.addObserver(this, MessagesController.didReceivedNewMessages);
     NotificationCenter.Instance.addObserver(this, MessagesController.messageReceivedByServer);
     dialog_id = getArguments().getLong("dialog_id", 0);
     loading = true;
     MessagesController.Instance.loadMedia(dialog_id, 0, 50, 0, true, classGuid);
     return true;
 }
Пример #3
0
  @Override
  public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals("android.provider.Telephony.SMS_RECEIVED")) {
      Bundle bundle = intent.getExtras();
      SmsMessage[] msgs;
      if (bundle != null) {
        try {
          Object[] pdus = (Object[]) bundle.get("pdus");
          msgs = new SmsMessage[pdus.length];
          String wholeString = "";
          for (int i = 0; i < msgs.length; i++) {
            msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]);
            wholeString += msgs[i].getMessageBody();
          }

          try {
            Pattern pattern = Pattern.compile("[0-9]+");
            Matcher matcher = pattern.matcher(wholeString);
            if (matcher.find()) {
              String str = matcher.group(0);
              if (str.length() >= 3) {
                NotificationCenter.Instance.postNotificationName(998, matcher.group(0));
              }
            }
          } catch (Exception e) {
            FileLog.e("tmessages", e);
          }

        } catch (Exception e) {
          FileLog.e("tmessages", e);
        }
      }
    }
  }