I'm building an application on Android Nougat, which will work constantly (in active mode and in a doze mode (when phone is sleep)). The problem is that after about 6 hours of inactivity Android stops the application.
There is a UI with activity and a service. The service uses bluetooth, network and recording to a local database. Approximately once per minute, bluetooth works and the result is recorded in the local database. After that, the data in the database is sent over the network. The service runs for 6 hours and after that its work stop. The notification is displayed but the service does not work. The manager.GetRunningServices method also indicates that the service is started but there are no signs of service.
I tried everything you can:
- The service uses the method StartForeground
- used wakeLock - does not help
- used the whitelist - prolongs for a couple of hours, but in the end, all the same, the service stops working
- Used the AlarmManager. It works constantly, but the code in OnReceive indicates that the service is running, but in fact it is not.
- I started the service in a separate process so that he would use as little memory as possible, but this also does not help.
Maybe someone has ideas about this?
Thank you.