use of com.android.tools.idea.run.AndroidRunConfigurationType in project android by JetBrains.
the class AndroidRunConfigurations method addRunConfiguration.
public void addRunConfiguration(@NotNull AndroidFacet facet, @Nullable String activityClass, @Nullable TargetSelectionMode targetSelectionMode, @Nullable String preferredAvdName) {
Module module = facet.getModule();
RunManager runManager = RunManager.getInstance(module.getProject());
AndroidRunConfigurationType runConfigurationType = AndroidRunConfigurationType.getInstance();
RunnerAndConfigurationSettings settings = runManager.createRunConfiguration(module.getName(), runConfigurationType.getFactory());
AndroidRunConfiguration configuration = (AndroidRunConfiguration) settings.getConfiguration();
configuration.setModule(module);
if (activityClass != null) {
configuration.setLaunchActivity(activityClass);
} else if (facet.getProjectType() == PROJECT_TYPE_INSTANTAPP) {
configuration.setLaunchUrl(getDefaultRunConfigurationUrl(facet));
} else if (isWatchFaceApp(facet)) {
// In case of a watch face app, there is only a service and no default activity that can be launched
// Eventually, we'd need to support launching a service, but currently you cannot launch a watch face service as well.
// See https://code.google.com/p/android/issues/detail?id=151353
configuration.MODE = DO_NOTHING;
} else {
configuration.MODE = LAUNCH_DEFAULT_ACTIVITY;
}
if (targetSelectionMode != null) {
configuration.getDeployTargetContext().setTargetSelectionMode(targetSelectionMode);
}
if (preferredAvdName != null) {
configuration.PREFERRED_AVD = preferredAvdName;
}
runManager.addConfiguration(settings, false);
runManager.setSelectedConfiguration(settings);
}
Aggregations