private void initialize() {
    mIdMap = new SparseArray<>();
    Display display;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
      mBackend = new DisplayListenerBackendImpl();
      // Make sure the display map contains the built-in primary display.
      // The primary display is never removed.
      display = getDisplayManager().getDisplay(Display.DEFAULT_DISPLAY);

      // Android documentation on Display.DEFAULT_DISPLAY suggests that the above
      // method might return null. In that case we retrieve the default display
      // from the application context and take it as the primary display.
      if (display == null) display = getDefaultDisplayForContext(getContext());
    } else {
      mBackend = new DisplayListenerAPI16();
      display = getDefaultDisplayForContext(getContext());
    }

    mMainSdkDisplayId = display.getDisplayId();
    addDisplay(display); // Note this display is never removed.

    mBackend.startListening();
  }
 /* package */ void stopAccurateListening() {
   mBackend.stopAccurateListening();
 }