增加停止服务的处理

main
Matthew 11 months ago
parent 0c65ec1d3b
commit a9a57086d1

@ -187,6 +187,7 @@ public class MainActivity extends AppCompatActivity {
if (mBound) {
Intent intent = new Intent((Context)this, ShellService.class);
this.bindService(intent, (ServiceConnection)this.connection, Context.BIND_AUTO_CREATE);
logger.info("Binded service");
}
this.setListener();
@ -195,9 +196,16 @@ public class MainActivity extends AppCompatActivity {
if (autoClose != 0) {
logger.info("Server stopped");
try {
MainActivity.this.stopShell();
} catch (Exception ex) {
logger.warning(ex.getMessage());
}
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
MainActivity.this.finish();
}
}, 2000);
@ -235,7 +243,7 @@ public class MainActivity extends AppCompatActivity {
public final void readLog() {
TextView logTextView = (TextView)this.findViewById(R.id.logTextView);
if (this.mBound) {
if (mBound) {
if (this.mService != null) {
logTextView.setText((CharSequence)this.mService.getOutput());
}

Loading…
Cancel
Save