@Override public void onCheckedChanged(CompoundButton compoundButton, boolean isEnable) { boolean enableSU = preferences.getBoolean("run_as_root", false); String execName = preferences.getString("use_server_httpd", "lighttpd"); String bindPort = preferences.getString("server_port", "8080"); if (isEnable) { context.startService(new Intent(context, ServerService.class)); CommandTask task = CommandTask.createForConnect(context, execName, bindPort); task.enableSU(enableSU); task.execute(); } else { CommandTask task = CommandTask.createForDisconnect(context); task.enableSU(enableSU); task.execute(); NotificationManager notify = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); notify.cancel(143); } }