Search in sources :

Example 1 with AndroidRunConfigurationType

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);
}
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)

Aggregations

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