增加停止服务的处理

main
Matthew 11 months ago
parent 0c65ec1d3b
commit a9a57086d1

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

Loading…
Cancel
Save