コード例 #1
1
  @Implementation
  public void setTo(Configuration o) {
    // commented out lines are coming in a newer version of Android SDK

    realConfiguration.fontScale = o.fontScale;
    realConfiguration.mcc = o.mcc;
    realConfiguration.mnc = o.mnc;
    if (o.locale != null) {
      realConfiguration.locale = (Locale) o.locale.clone();
      // realConfiguration.textLayoutDirection = o.textLayoutDirection;
    }
    // realConfiguration.userSetLocale = o.userSetLocale;
    realConfiguration.touchscreen = o.touchscreen;
    realConfiguration.keyboard = o.keyboard;
    realConfiguration.keyboardHidden = o.keyboardHidden;
    realConfiguration.hardKeyboardHidden = o.hardKeyboardHidden;
    realConfiguration.navigation = o.navigation;
    realConfiguration.navigationHidden = o.navigationHidden;
    realConfiguration.orientation = o.orientation;
    realConfiguration.screenLayout = o.screenLayout;
    realConfiguration.uiMode = o.uiMode;
    realConfiguration.screenWidthDp = o.screenWidthDp;
    realConfiguration.screenHeightDp = o.screenHeightDp;
    realConfiguration.smallestScreenWidthDp = o.smallestScreenWidthDp;
    // realConfiguration.compatScreenWidthDp = o.compatScreenWidthDp;
    // realConfiguration.compatScreenHeightDp = o.compatScreenHeightDp;
    // realConfiguration.compatSmallestScreenWidthDp = o.compatSmallestScreenWidthDp;
    // realConfiguration.seq = o.seq;
  }
  /** Change the configuration used when retrieving resources. Not for use by applications. */
  @Override
  public void setConfiguration(
      int mcc,
      int mnc,
      String locale,
      int orientation,
      int touchscreen,
      int density,
      int keyboard,
      int keyboardHidden,
      int navigation,
      int screenWidth,
      int screenHeight,
      int version) {

    Configuration c = new Configuration();
    c.mcc = mcc;
    c.mnc = mnc;
    c.locale = new Locale(locale);
    c.touchscreen = touchscreen;
    c.keyboard = keyboard;
    c.keyboardHidden = keyboardHidden;
    c.navigation = navigation;
    c.orientation = orientation;
  }