当前位置: 首页>>代码示例>>Java>>正文


Java AndroidVersion.getApiLevel方法代码示例

本文整理汇总了Java中com.android.sdklib.AndroidVersion.getApiLevel方法的典型用法代码示例。如果您正苦于以下问题:Java AndroidVersion.getApiLevel方法的具体用法?Java AndroidVersion.getApiLevel怎么用?Java AndroidVersion.getApiLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.android.sdklib.AndroidVersion的用法示例。


在下文中一共展示了AndroidVersion.getApiLevel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getHighestApi

import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
private static int getHighestApi(PsiElement element) {
  int max = SdkVersionInfo.HIGHEST_KNOWN_STABLE_API;
  AndroidFacet instance = AndroidFacet.getInstance(element);
  if (instance != null) {
    AndroidSdkData sdkData = instance.getSdkData();
    if (sdkData != null) {
      for (IAndroidTarget target : sdkData.getTargets()) {
        if (target.isPlatform()) {
          AndroidVersion version = target.getVersion();
          if (version.getApiLevel() > max && !version.isPreview()) {
            max = version.getApiLevel();
          }
        }
      }
    }
  }
  return max;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:AndroidLintInspectionToolProvider.java

示例2: getBuildSdk

import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
@Override
public int getBuildSdk() {
  IdeaAndroidProject ideaAndroidProject = myFacet.getIdeaAndroidProject();
  if (ideaAndroidProject != null) {
    String compileTarget = ideaAndroidProject.getDelegate().getCompileTarget();
    AndroidVersion version = AndroidTargetHash.getPlatformVersion(compileTarget);
    if (version != null) {
      return version.getApiLevel();
    }
  }

  AndroidPlatform platform = AndroidPlatform.getInstance(myFacet.getModule());
  if (platform != null) {
    return platform.getApiLevel();
  }

  return super.getBuildSdk();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:IntellijLintProject.java

示例3: isOptionalForSdkLocation

import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
@Override
public boolean isOptionalForSdkLocation(@Nullable SdkManager manager) {
  LocalPkgInfo[] infos = getPlatformPackages(manager);
  if (infos.length == 0) {
    return !myIsDefaultPlatform;
  }
  for (LocalPkgInfo info : infos) {
    IPkgDesc desc = info.getDesc();
    // No unchecking if the platform is already installed. We can update but not remove existing platforms
    AndroidVersion androidVersion = desc.getAndroidVersion();
    int apiLevel = androidVersion == null ? 0 : androidVersion.getApiLevel();
    if (myVersion.getFeatureLevel() == apiLevel) {
      return false;
    }
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:Platform.java

示例4: checkForUpgrades

import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
/**
 * Look through the list of completed changes, and set a key if any new platforms
 * were installed.
 */
private void checkForUpgrades(@Nullable List completedChanges) {
  if (completedChanges == null) {
    return;
  }
  int highestNewApiLevel = 0;
  for (Object o : completedChanges) {
    if (! (o instanceof IPkgDesc)) {
      continue;
    }
    IPkgDesc pkgDesc = (IPkgDesc)o;
    if (pkgDesc.getType().equals(PkgType.PKG_PLATFORM)) {
      AndroidVersion version = pkgDesc.getAndroidVersion();
      if (version != null && version.getApiLevel() > highestNewApiLevel) {
        highestNewApiLevel = version.getApiLevel();
      }
    }
  }
  if (highestNewApiLevel > 0) {
    myState.put(NEWLY_INSTALLED_API_KEY, highestNewApiLevel);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:SmwOldApiDirectInstall.java

示例5: canBeUpdatedBy

import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 * <hr>
 * Doc packages are a bit different since there can only be one doc installed at
 * the same time.
 * <p/>
 * We now consider that docs for different APIs are NOT updates, e.g. doc for API N+1
 * is no longer considered an update for doc API N.
 * However docs that have the same API version (API level + codename) are considered
 * updates if they have a higher revision number (so 15 rev 2 is an update for 15 rev 1,
 * but is not an update for 14 rev 1.)
 */
@Override
public UpdateInfo canBeUpdatedBy(Package replacementPackage) {
    // check they are the same kind of object
    if (!(replacementPackage instanceof DocPackage)) {
        return UpdateInfo.INCOMPATIBLE;
    }

    DocPackage replacementDoc = (DocPackage)replacementPackage;

    AndroidVersion replacementVersion = replacementDoc.getAndroidVersion();

    // Check if they're the same exact (api and codename)
    if (replacementVersion.equals(mVersion)) {
        // exact same version, so check the revision level
        if (replacementPackage.getRevision().compareTo(this.getRevision()) > 0) {
            return UpdateInfo.UPDATE;
        }
    } else {
        // not the same version? we check if they have the same api level and the new one
        // is a preview, in which case it's also an update (since preview have the api level
        // of the _previous_ version.)
        if (replacementVersion.getApiLevel() == mVersion.getApiLevel() &&
                replacementVersion.isPreview()) {
            return UpdateInfo.UPDATE;
        }
    }

    // not an upgrade but not incompatible either.
    return UpdateInfo.NOT_UPDATE;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:43,代码来源:DocPackage.java

示例6: findBestTarget

import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
@Nullable
private static IAndroidTarget findBestTarget(@NotNull IAndroidTarget[] targets) {
  IAndroidTarget bestTarget = null;
  int maxApiLevel = -1;
  for (IAndroidTarget target : targets) {
    AndroidVersion version = target.getVersion();
    if (target.isPlatform() && !version.isPreview() && version.getApiLevel() > maxApiLevel) {
      bestTarget = target;
      maxApiLevel = version.getApiLevel();
    }
  }
  return bestTarget;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:AndroidSdkUtils.java

示例7: findLatestCompatibleBuildTool

import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
private static FullRevision findLatestCompatibleBuildTool(@Nullable Multimap<PkgType, RemotePkgInfo> remotePackages,
                                                          AndroidVersion version) {
  FullRevision revision = null;
  if (remotePackages != null) {
    for (RemotePkgInfo remotePkgInfo : remotePackages.get(PkgType.PKG_BUILD_TOOLS)) {
      FullRevision testRevision = remotePkgInfo.getPkgDesc().getFullRevision();
      if (testRevision != null &&
          testRevision.getMajor() == version.getApiLevel() && (revision == null || testRevision.compareTo(revision) > 0)) {
        revision = testRevision;
      }
    }
  }
  return revision;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:Platform.java

示例8: configureLanguageLevel

import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
/**
 * Determines the java language level to use and sets it on the given task and
 * {@link CompileOptions}. The latter is to propagate the information to Studio.
 */
public static void configureLanguageLevel(
        AbstractCompile compileTask,
        final CompileOptions compileOptions,
        String compileSdkVersion) {
    final AndroidVersion hash = AndroidTargetHash.getVersionFromHash(compileSdkVersion);
    Integer compileSdkLevel = (hash == null ? null : hash.getApiLevel());

    JavaVersion javaVersionToUse;
    if (compileSdkLevel == null || (0 <= compileSdkLevel && compileSdkLevel <= 20)) {
        javaVersionToUse = JavaVersion.VERSION_1_6;
    } else {
        javaVersionToUse = JavaVersion.VERSION_1_7;
    }

    JavaVersion jdkVersion =
            JavaVersion.toVersion(System.getProperty("java.specification.version"));
    if (jdkVersion.compareTo(javaVersionToUse) < 0) {
        compileTask.getLogger().warn(
                "Default language level for compileSdkVersion '{}' is " +
                        "{}, but the JDK used is {}, so the JDK language level will be used.",
                compileSdkVersion,
                javaVersionToUse,
                jdkVersion);
        javaVersionToUse = jdkVersion;
    }

    compileOptions.setDefaultJavaVersion(javaVersionToUse);

    ConventionMappingHelper.map(compileTask, "sourceCompatibility", new Callable<String>() {
        @Override
        public String call() throws Exception {
            return compileOptions.getSourceCompatibility().toString();
        }
    });

    ConventionMappingHelper.map(compileTask, "targetCompatibility", new Callable<String>() {
        @Override
        public String call() throws Exception {
            return compileOptions.getTargetCompatibility().toString();
        }
    });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:47,代码来源:AbstractCompilesUtil.java

示例9: clone

import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
public static ApiVersion clone(@NonNull AndroidVersion androidVersion) {
    return new ApiVersionImpl(androidVersion.getApiLevel(), androidVersion.getCodename());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:ApiVersionImpl.java

示例10: createPopupActionGroup

import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
@Override
@NotNull
protected DefaultActionGroup createPopupActionGroup(JComponent button) {
  DefaultActionGroup group = new DefaultActionGroup(null, true);

  Configuration configuration = myRenderContext.getConfiguration();
  if (configuration == null) {
    return group;
  }

  group.add(new TogglePickBestAction(configuration.getConfigurationManager()));
  group.addSeparator();

  IAndroidTarget current = configuration.getTarget();
  IAndroidTarget[] targets = configuration.getConfigurationManager().getTargets();

  boolean haveRecent = false;

  Module module = myRenderContext.getModule();
  int minSdk = -1;
  if (module != null) {
    AndroidFacet facet = AndroidFacet.getInstance(module);
    if (facet != null) {
      minSdk = facet.getAndroidModuleInfo().getMinSdkVersion().getFeatureLevel();
    }
  }

  for (int i = targets.length - 1; i >= 0; i--) {
    IAndroidTarget target = targets[i];
    if (!ConfigurationManager.isLayoutLibTarget(target)) {
      continue;
    }

    if (!switchToTargetAllowed(configuration, target)) {
      continue;
    }

    AndroidVersion version = target.getVersion();
    if (version.getFeatureLevel() < minSdk) {
      continue;
    }
    if (version.getApiLevel() >= 7) {
      haveRecent = true;
    }
    else if (haveRecent) {
      // Don't show ancient rendering targets; they're pretty broken
      // (unless of course all you have are ancient targets)
      break;
    }

    String title = getRenderingTargetLabel(target, false);
    boolean select = current == target;
    group.add(new SetTargetAction(myRenderContext, title, target, select));
  }

  group.addSeparator();
  RenderPreviewMode currentMode = RenderPreviewMode.getCurrent();
  if (currentMode != RenderPreviewMode.API_LEVELS) {
    ConfigurationMenuAction.addApiLevelPreviewAction(myRenderContext, group);
  } else {
    ConfigurationMenuAction.addRemovePreviewsAction(myRenderContext, group);
  }

  return group;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:66,代码来源:TargetMenuAction.java

示例11: getBuildSdkApiLevel

import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
public static int getBuildSdkApiLevel(@Nullable Module module) {
  AndroidVersion version = getBuildSdkVersion(module);
  return version != null ? version.getApiLevel() : -1;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:AndroidModuleInfo.java

示例12: deriveValues

import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
/**
 * Fill in the values that can be derived from the selected min SDK level:
 *
 * minApiLevel will be set to the selected api level (string or number)
 * minApi will be set to the numerical equivalent
 * buildApi will be set to the highest installed platform, or to the preview platform if a preview is selected
 * buildApiString will be set to the corresponding string
 * targetApi will be set to the highest installed platform or to the preview platform if a preview is selected
 * targetApiString will be set to the corresponding string
 * @param stateStore
 * @param modified
 */
public void deriveValues(@NotNull ScopedStateStore stateStore, @NotNull Set<Key> modified) {
  if (modified.contains(myTargetComboBoxKey) || modified.contains(myInclusionKey)) {
    AndroidTargetComboBoxItem targetItem = stateStore.get(myTargetComboBoxKey);
    if (targetItem == null) {
      return;
    }
    stateStore.put(getMinApiKey(myFormFactor), targetItem.id.toString());
    stateStore.put(getMinApiLevelKey(myFormFactor), targetItem.apiLevel);
    IAndroidTarget target = targetItem.target;
    if (target != null && (target.getVersion().isPreview() || !target.isPlatform())) {
      // Make sure we set target and build to the preview version as well
      populateApiLevels(targetItem.apiLevel, target, stateStore);
    } else {
      int targetApiLevel;
      if (ourHighestInstalledApiTarget != null) {
        targetApiLevel = ourHighestInstalledApiTarget.getVersion().getFeatureLevel();
      } else {
        targetApiLevel = 0;
      }
      populateApiLevels(targetApiLevel, ourHighestInstalledApiTarget, stateStore);
    }
    // Check to see if this is installed. If not, request that we install it
    if (myInstallRequest != null) {
      // First remove the last request, no need to install more than one platform
      stateStore.listRemove(INSTALL_REQUESTS_KEY, myInstallRequest);
    }
    if (target == null) {
      AndroidVersion androidVersion = new AndroidVersion(targetItem.apiLevel, null);
      // TODO: If the user has no APIs installed, we then request to install whichever version the user has targeted here.
      // Instead, we should choose to install the highest stable API possible. However, users having no SDK at all installed is pretty
      // unlikely, so this logic can wait for a followup CL.
      if (ourHighestInstalledApiTarget == null ||
          (androidVersion.getApiLevel() > ourHighestInstalledApiTarget.getVersion().getApiLevel() &&
           !ourInstalledVersions.contains(androidVersion) &&
           stateStore.get(myInclusionKey))) {
        IPkgDesc platformDescription =
          PkgDesc.Builder.newPlatform(androidVersion, new MajorRevision(1), FullRevision.NOT_SPECIFIED).create();
        stateStore.listPush(INSTALL_REQUESTS_KEY, platformDescription);
        myInstallRequest = platformDescription;
        populateApiLevels(androidVersion.getApiLevel(), ourHighestInstalledApiTarget, stateStore);
      }
    }
    PropertiesComponent.getInstance().setValue(getPropertiesComponentMinSdkKey(myFormFactor), targetItem.id.toString());

    // Check Java language level; should be 7 for L; eventually this will be automatically defaulted by the Android Gradle plugin
    // instead: https://code.google.com/p/android/issues/detail?id=76252
    String javaVersion = null;
    if (ourHighestInstalledApiTarget != null && ourHighestInstalledApiTarget.getVersion().getFeatureLevel() >= 21) {
      AndroidSdkData sdkData = AndroidSdkUtils.tryToChooseAndroidSdk();
      if (sdkData != null) {
        JavaSdk jdk = JavaSdk.getInstance();
        Sdk sdk = ProjectJdkTable.getInstance().findMostRecentSdkOfType(jdk);
        if (sdk != null) {
          JavaSdkVersion version = jdk.getVersion(sdk);
          if (version != null && version.isAtLeast(JavaSdkVersion.JDK_1_7)) {
            javaVersion = JavaSdkVersion.JDK_1_7.getDescription();
          }
        }
      }
    }
    stateStore.put(getLanguageLevelKey(myFormFactor), javaVersion);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:76,代码来源:FormFactorApiComboBox.java

示例13: isIncompatibleMinSdk

import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
private boolean isIncompatibleMinSdk(@NotNull TemplateEntry template) {
  AndroidVersion minSdk = myState.get(AddAndroidActivityPath.KEY_MIN_SDK);
  return minSdk != null && minSdk.getApiLevel() < template.getMinSdk();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:ActivityGalleryStep.java

示例14: getMinSdk

import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
/**
 * Returns the minimum API <b>level</b> requested by the manifest, or -1 if not
 * specified. Use {@link #getMinSdkVersion()} to get a full version if you need
 * to check if the platform is a preview platform etc.
 *
 * @return the minimum API level or -1 if unknown
 */
public int getMinSdk() {
    AndroidVersion version = getMinSdkVersion();
    return version == AndroidVersion.DEFAULT ? -1 : version.getApiLevel();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:Project.java

示例15: getTargetSdk

import com.android.sdklib.AndroidVersion; //导入方法依赖的package包/类
/**
 * Returns the target API <b>level</b> specified by the manifest, or -1 if not
 * specified. Use {@link #getTargetSdkVersion()} to get a full version if you need
 * to check if the platform is a preview platform etc.
 *
 * @return the target API level or -1 if unknown
 */
public int getTargetSdk() {
    AndroidVersion version = getTargetSdkVersion();
    return version == AndroidVersion.DEFAULT ? -1 : version.getApiLevel();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:Project.java


注:本文中的com.android.sdklib.AndroidVersion.getApiLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。