| | |
| | | @Override |
| | | public void onReceive(Context context, Intent intent) { |
| | | lastOnReceive = System.currentTimeMillis(); |
| | | // System.out.println("KeepLifeService.onReceive"); |
| | | // System1.out.println("KeepLifeService.onReceive"); |
| | | } |
| | | }; |
| | | private String mPackName; |
| | |
| | | BaseApplication.getApplication().executorService.execute(() -> { |
| | | while (running) { |
| | | try { |
| | | // System.out.println("KeepLifeService.run " + Thread.currentThread().getId()); |
| | | // System1.out.println("KeepLifeService.run " + Thread.currentThread().getId()); |
| | | SystemClock.sleep(2 * 1000); |
| | | if (Constants.autoRestart) { |
| | | boolean isRun = isRunningProcess(mActivityManager, mPackName); |
| | |
| | | try { |
| | | BaseApplication.getApplication().executorService.execute(() -> { |
| | | while (running) { |
| | | // System.out.println("服务正在运行..." + Thread.currentThread().getId()); |
| | | // System1.out.println("服务正在运行..." + Thread.currentThread().getId()); |
| | | try { |
| | | Thread.sleep(2 * 1000); |
| | | if (Constants.autoRestart) { |
| | |
| | | unregisterReceiver(keepLifeReceiver); |
| | | running = false; |
| | | stopForeground(true); |
| | | // System.out.println("KeepLifeService.onDestroy"); |
| | | // System1.out.println("KeepLifeService.onDestroy"); |
| | | } |
| | | } |