public void updateMissedChatCount() {
   displayMissedChats(getChatStorage().getUnreadMessageCount());
 }
  public void displayChat(String sipUri) {
    if (getResources().getBoolean(R.bool.disable_chat)) {
      return;
    }

    LinphoneAddress lAddress;
    try {
      lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
    } catch (LinphoneCoreException e) {
      Log.e("Cannot display chat", e);
      return;
    }
    Contact contact =
        ContactsManager.getInstance().findContactWithAddress(getContentResolver(), lAddress);
    String displayName = contact != null ? contact.getName() : null;

    String pictureUri = null;
    String thumbnailUri = null;
    if (contact != null && contact.getPhotoUri() != null) {
      pictureUri = contact.getPhotoUri().toString();
      thumbnailUri = contact.getThumbnailUri().toString();
    }

    if (isTablet()) {
      if (currentFragment == FragmentsAvailable.CHATLIST
          || currentFragment == FragmentsAvailable.CHAT) {
        Fragment fragment2 = getSupportFragmentManager().findFragmentById(R.id.fragmentContainer2);
        if (fragment2 != null
            && fragment2.isVisible()
            && currentFragment == FragmentsAvailable.CHAT) {
          ChatFragment chatFragment = (ChatFragment) fragment2;
          chatFragment.changeDisplayedChat(sipUri, displayName, pictureUri);
        } else {
          Bundle extras = new Bundle();
          extras.putString("SipUri", sipUri);
          if (contact != null) {
            extras.putString("DisplayName", displayName);
            extras.putString("PictureUri", pictureUri);
            extras.putString("ThumbnailUri", thumbnailUri);
          }
          changeCurrentFragment(FragmentsAvailable.CHAT, extras);
        }
      } else {
        changeCurrentFragment(FragmentsAvailable.CHATLIST, null);
        displayChat(sipUri);
      }
      if (messageListFragment != null && messageListFragment.isVisible()) {
        ((ChatListFragment) messageListFragment).refresh();
      }
    } else {
      Intent intent = new Intent(this, ChatActivity.class);
      intent.putExtra("SipUri", sipUri);
      if (contact != null) {
        intent.putExtra("DisplayName", contact.getName());
        intent.putExtra("PictureUri", pictureUri);
        intent.putExtra("ThumbnailUri", thumbnailUri);
      }
      startOrientationSensor();
      startActivityForResult(intent, CHAT_ACTIVITY);
    }

    LinphoneService.instance().resetMessageNotifCount();
    LinphoneService.instance().removeMessageNotification();
    displayMissedChats(getChatStorage().getUnreadMessageCount());
  }