There is an old Android app which work background 2 service (Service).
It took to update the app with the possibility of sending data and logging while working is no
Here is some useful information on Idle Mode:
deviceidle - Is a new android service, that will always run and listen for the several system events, which can trigger it in/out of the idle mode (also known as a Doze mode):
1.Screen on/off
2.Charging status
3.Significant motion detect
DeviceIdleController - When the device is awake and in-use, the controller is in the ACTIVE state. External events like inactivity time-out, user powering off the screen, motion detection ... will drive the state machine into INACTIVE. This state machine contains seven states:
1.ACTIVE - Device is in use, or connected to a charge source.
2.INACTIVE - Device has recently come out of the active state, meaning that user turned off the display or unplugged it.
3.IDLE_PENDING - Hold on, we are about to enter idle mode.
4.SENSING
5.LOCATING
6.IDLE - Device is idle.
7.IDLE_MAINTENANCE - Window is open for applications to do processing. Then will back to IDLE.
Idle State - In order to put the device into an Idle state you can use the following adb commands:
>adb shell dumpsys battery unplug
>adb shell dumpsys deviceidle force-idle
Active State - In order to put the device back into the Active state you may simulate the following key event:
> adb shell input keyevent KEYCODE_WAKEUP
I also needed a quick option to toggle between Active and Idle states so I wrote a batch script adbIdleModeSwitch.bat for these purposes, you may download and use it: https://drive.google.com/file/d/0B81qFnPX_eUUYTMxOTd1UG94NVk/view