异常保护

main
Matthew 9 months ago
parent 918c7eb5b5
commit 34550a1287

@ -189,12 +189,16 @@ 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");
try {
Intent intent = new Intent((Context) this, ShellService.class);
bindService(intent, (ServiceConnection) this.connection, Context.BIND_AUTO_CREATE);
logger.info("Binded service");
} catch (Exception ex) {
logger.warning(ex.getMessage());
}
}
this.setListener();
setListener();
state_switch.setChecked(mBound || (startFrp != 0));
@ -222,7 +226,7 @@ public class MainActivity extends AppCompatActivity {
}
private final void setListener() {
Button configButton = (Button)this.findViewById(R.id.configButton);
Button configButton = (Button)findViewById(R.id.configButton);
configButton.setOnClickListener((View.OnClickListener)(new View.OnClickListener() {
public final void onClick(View it) {
Intent intent = new Intent((Context)MainActivity.this, ConfigActivity.class);
@ -231,13 +235,13 @@ public class MainActivity extends AppCompatActivity {
}
}));
Button refreshButton = (Button)this.findViewById(R.id.refreshButton);
Button refreshButton = (Button)findViewById(R.id.refreshButton);
refreshButton.setOnClickListener((View.OnClickListener)(new View.OnClickListener() {
public final void onClick(View it) {
MainActivity.this.readLog();
}
}));
Button deleteButton = (Button)this.findViewById(R.id.deleteButton);
Button deleteButton = (Button)findViewById(R.id.deleteButton);
deleteButton.setOnClickListener((View.OnClickListener)(new View.OnClickListener() {
public final void onClick(View it) {
MainActivity.this.mService.clearOutput();
@ -247,10 +251,10 @@ public class MainActivity extends AppCompatActivity {
}
public final void readLog() {
TextView logTextView = (TextView)this.findViewById(R.id.logTextView);
TextView logTextView = (TextView)findViewById(R.id.logTextView);
if (mBound) {
if (this.mService != null) {
logTextView.setText((CharSequence)this.mService.getOutput());
if (mService != null) {
logTextView.setText((CharSequence)mService.getOutput());
}
} else {
Log.w("adx", "readLog mBound==null");
@ -313,16 +317,20 @@ public class MainActivity extends AppCompatActivity {
} else {
startService(intent);
}
this.bindService(intent, (ServiceConnection) this.connection, Context.BIND_AUTO_CREATE);
bindService(intent, (ServiceConnection) connection, Context.BIND_AUTO_CREATE);
} catch (Exception ex) {
logger.warning(ex.getMessage());
}
}
private final void stopShell() {
Intent intent = new Intent((Context)this, ShellService.class);
this.unbindService((ServiceConnection)this.connection);
this.stopService(intent);
try {
Intent intent = new Intent((Context) this, ShellService.class);
unbindService((ServiceConnection) connection);
stopService(intent);
} catch (Exception ex) {
ex.printStackTrace();
}
}
private final void checkNotificationPermission() {

Loading…
Cancel
Save