diff --git a/app/src/main/java/com/example/bpa/MainActivity.java b/app/src/main/java/com/example/bpa/MainActivity.java index 0e3aca8..cc8bead 100644 --- a/app/src/main/java/com/example/bpa/MainActivity.java +++ b/app/src/main/java/com/example/bpa/MainActivity.java @@ -43,6 +43,7 @@ import com.example.bpa.helper.MQTT; import com.example.bpa.helper.MessageLog; import com.example.bpa.helper.ModbusTcpHelper; import com.example.bpa.helper.ModbusTcpServer; +import com.example.bpa.helper.NetworkUtils; import com.example.bpa.helper.Speech; import com.example.bpa.helper.T; import com.example.bpa.helper.ThreadManager; @@ -175,6 +176,7 @@ public class MainActivity extends FragmentActivity implements View.OnClickListen * 初始化业务 */ private void initBusiness() { + NetworkUtils.SynchronizationTime();//同步时间 Main.getInstance().ToggleEnvironment(); //PLC数据监控 //PLC数据监控 diff --git a/app/src/main/java/com/example/bpa/app/ICSApp.java b/app/src/main/java/com/example/bpa/app/ICSApp.java index ba05085..369ac24 100644 --- a/app/src/main/java/com/example/bpa/app/ICSApp.java +++ b/app/src/main/java/com/example/bpa/app/ICSApp.java @@ -34,6 +34,7 @@ public class ICSApp extends Application { public void onCreate() { super.onCreate(); NetworkUtils.exec3("ip rule add from all lookup main pref 9999"); + NetworkUtils.SynchronizationTime();//同步时间 ConfigName.getInstance().dishesCon = this; ConfigName.getInstance().app = this; } diff --git a/app/src/main/java/com/example/bpa/helper/NetworkUtils.java b/app/src/main/java/com/example/bpa/helper/NetworkUtils.java index 32c02f0..7a750cc 100644 --- a/app/src/main/java/com/example/bpa/helper/NetworkUtils.java +++ b/app/src/main/java/com/example/bpa/helper/NetworkUtils.java @@ -172,7 +172,24 @@ public class NetworkUtils { }); } + /** + * 同步时间 + */ + public static void SynchronizationTime() + { + new Thread(new Runnable() { + @Override + public void run() { + try { + exec3("settings put global auto_time 0"); + Thread.sleep(500); + exec3("settings put global auto_time 1"); + } catch (InterruptedException e) { + } + } + }).start(); + } /** * 发送 * @param cmds