Search in sources :

Example 1 with AndroidRunConfiguration

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);
}
Also used : AndroidRunConfigurationType(com.android.tools.idea.run.AndroidRunConfigurationType) RunnerAndConfigurationSettings(com.intellij.execution.RunnerAndConfigurationSettings) AndroidRunConfiguration(com.android.tools.idea.run.AndroidRunConfiguration) Module(com.intellij.openapi.module.Module) RunManager(com.intellij.execution.RunManager)

Example 2 with AndroidRunConfiguration

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);
}
Also used : RunConfiguration(com.intellij.execution.configurations.RunConfiguration) AndroidRunConfiguration(com.android.tools.idea.run.AndroidRunConfiguration) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory) AndroidRunConfiguration(com.android.tools.idea.run.AndroidRunConfiguration) Module(com.intellij.openapi.module.Module)

Aggregations

AndroidRunConfiguration (com.android.tools.idea.run.AndroidRunConfiguration)2 Module (com.intellij.openapi.module.Module)2 AndroidRunConfigurationType (com.android.tools.idea.run.AndroidRunConfigurationType)1 RunManager (com.intellij.execution.RunManager)1 RunnerAndConfigurationSettings (com.intellij.execution.RunnerAndConfigurationSettings)1 ConfigurationFactory (com.intellij.execution.configurations.ConfigurationFactory)1 RunConfiguration (com.intellij.execution.configurations.RunConfiguration)1