Android battery consumption rates

I’m having some issues with battery consumption on Android. The problem isn’t with the drain on battery while in use, but rather with the background consumption: battery drains much faster (though cpu use drops from 25% to about 5%) when opened in the background (vs app closed altogether, not vs active). What’s worse, when the lock screen gets engaged it leaves the app sucking battery at full speed. The suspend function never gets called from what I can see. Any ideas?

Are you doing Audio processing?

Yes I am. I thought that might be the problem from something I’d seen elsewhere. Does the suspend function not get called with audio apps? If so can that be rectified?

Ok, here’s something that helped a lot :

void resumed () override 
    void suspended () override

There was a false positive on the above code. Now I’m calling AudioDeviceManager:: closeAudioDevice() from suspend(). Which saves the battery well. Only problem is when I try in resumed() to reload it (either with the AudioDeviceManager::initialise or AudioDeviceManager:: restartLastAudioDevice) it crashes. The documentation says setAudioDevice needs to be called and the only function I can find is AudioDeviceManager:: setAudioDeviceSetup. Any helpful ideas?


Found a solution. This time I’m pretty sure it’s solid. Call the following two functions for start and stop respectively:

audiodevicemanager->getCurrentAudioDevice ()->stop();
audiodevicemanager->getCurrentAudioDevice ()->start(audiosourceplayer);