I have an Android App. It has a background service that collects sensor data and sends it to a cloud provider.
The service runs reliably when the screen is on. It runs most of the time when the screen is off. There is no error that interrupts it.
However, sometimes when the screen is off the data transmission will stop.
My thought was that the phone was shutting off the CPU. I added the wake lock as per the Android documentation:
PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "MyWakelockTag");
wakeLock.acquire();
The problem continues. Is there such a thing as a WiFi or Cell Data wake lock?