public void click(View view) throws IOException { if (_service == null || !_service.isStarted()) { // Ensure device is rooted if SU is activated if (!checkRoot()) { // Display error dialog AlertDialog.Builder builder = new AlertDialog.Builder(this); builder .setMessage(R.string.no_su_error) .setCancelable(false) .setNegativeButton( android.R.string.cancel, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); } else { // Start tincd service Intent intent = new Intent(this, TincdService.class); startService(intent); } } else { Log.d(Tools.TAG, "Requesting stop"); _service.stopTincd(); } }
private void updateStatus() { if (_service != null && _service.isStarted()) { _txtView.setText("Started"); _startStopButton.setText(getText(R.string.stop)); _debugButton.setEnabled(true); } else { _txtView.setText("Stopped"); _startStopButton.setText(getText(R.string.start)); _debugButton.setEnabled(false); } if (_service != null) _debugButton.setChecked(_service._debug); else _debugButton.setChecked(false); }