use of com.android.tools.idea.run.AndroidRunConfiguration 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);
}
use of com.android.tools.idea.run.AndroidRunConfiguration in project android by JetBrains.
the class AndroidRunConfigurations method createRunConfiguration.
public void createRunConfiguration(@NotNull AndroidFacet facet) {
Module module = facet.getModule();
ConfigurationFactory configurationFactory = AndroidRunConfigurationType.getInstance().getFactory();
List<RunConfiguration> configurations = RunManager.getInstance(module.getProject()).getConfigurationsList(configurationFactory.getType());
for (RunConfiguration configuration : configurations) {
if (configuration instanceof AndroidRunConfiguration && ((AndroidRunConfiguration) configuration).getConfigurationModule().getModule() == module) {
// There is already a run configuration for this module.
return;
}
}
addRunConfiguration(facet, null, TargetSelectionMode.SHOW_DIALOG, null);
}
Aggregations