I get time with
Date today = new Date(); SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("HH:mm"); String date = DATE_FORMAT.format(today); and send to server. The server processes them.
The problem is that the service sometimes stops sending data. The service falls asleep for 2 minutes and then wakes up by itself.
How to be? I added a shutdown of optimization to my application in the battery menu, but still the service goes to sleep and wakes itself up. Yes, and on charging the service does not fall asleep. That is, I connect the phone to the laptop, I want to see what the problem is through monitoring (the service works as it should). I think this is due to the fact that it is connected to the laptop and is charging. But it did not help me to understand the problem (I’ve added the application to the list of those that were turned off from optimization).
How to understand this behavior?