Is it possible to run the selected configuration without persisting it?


Regards to an Android Studio plugin,
I want to run the "selected/activty configuration" with temporary parameter (like setting the "launch Activity").
I managed to do it by the attached code, but the change is persisted.
  Is it possible to achieve the goal wihtout persisting it? Thanks.


public void testAction(AnActionEvent e) {
    RunManager manager = RunManager.getInstance(e.getProject());
RunnerAndConfigurationSettings selectedConfiguration = manager.getSelectedConfiguration();
RunConfiguration conf = selectedConfiguration.getConfiguration();
(! (conf instanceof AndroidRunConfiguration)) {

    AndroidRunConfiguration anConf = (AndroidRunConfiguration) conf;

    // change the target Activity -- Note: it will change the stored configuration

Project project = e.getData(PlatformDataKeys.PROJECT);

ProgramRunnerUtil.executeConfiguration(project, selectedConfiguration,
1 comment
Comment actions Permalink

Sorry for late reply. You can try the following: create a copy of selectedConfiguration by calling 'clone' method on it (RunnerAndConfigurationSettingsImpl implements Cloneable), then modify the copy and start it.


Please sign in to leave a comment.