修复启停服务的bug

serial
Matthew 2 years ago
parent 977f8ef151
commit efb42cedaf

@ -267,7 +267,7 @@ public class MainActivity extends AppCompatActivity {
AppConfig curAppConfig = retrieveAndSaveAppConfig();
if (TextUtils.isEmpty(appConfig.cmdid) || TextUtils.isEmpty(appConfig.server) || appConfig.port == 0) {
if (TextUtils.isEmpty(curAppConfig.cmdid) || TextUtils.isEmpty(curAppConfig.server) || curAppConfig.port == 0) {
return;
}
Intent intent = new Intent(MainActivity.this, MicroPhotoService.class);
@ -576,15 +576,19 @@ public class MainActivity extends AppCompatActivity {
dataPath.mkdirs();
}
inputStreamReader = new InputStreamReader(new FileInputStream(new File(appPath + "App.json")), "UTF-8");
StringBuilder stringBuilder = new StringBuilder();
File file = new File(dataPath, "App.json");
if (file.exists()) {
inputStreamReader = new InputStreamReader(new FileInputStream(file), "UTF-8");
bufferedReader = new BufferedReader(inputStreamReader);
String line;
StringBuilder stringBuilder = new StringBuilder();
while ((line = bufferedReader.readLine()) != null) {
stringBuilder.append(line);
}
}
JSONObject jsonObject = new JSONObject(stringBuilder.toString());
JSONObject jsonObject =stringBuilder.length() > 0 ? (new JSONObject(stringBuilder.toString())) : (new JSONObject());
jsonObject.put("CMDID", cmdid);
jsonObject.put("Server", server);

Loading…
Cancel
Save