I have developed a voice recording app using WasApi for Windows Phone 8. But users are facing battery problem a lot and also the screen is not getting timeout while the recording is on. And if users press the lock button on background recording is getting paused. Can anyone tell me how to solve these issues?
-
1Don't display anything bright on the screen, and don't use any `while(true)` loops if you can use `sleep`. – Peter Sep 17 '14 at 07:14
-
1Oh, and don't refresh the screen all the time with a fancy animation. A black background with a small red dot and maybe the word "recording" in red is sufficient. Maybe also the current length of the recording that updates every second (don't display milliseconds). The screen is the biggest power draw. The processor is the second biggest, if you won't let it sleep. – Peter Sep 17 '14 at 07:21
-
Can we reduce the screen brightness programmatically? @Peter – Krrish Sep 17 '14 at 07:37
-
I don't know by heart because this can change with every new release, but I'm pretty sure you cannot. Rule of thumb: You cannot change any settings (you can open a settings screen tough), and you cannot run in the background in a way that allows doing anything useful. Maybe you can turn the screen off? Keep in mind most Lumias have no problem lasting on a battery for days even with Glance on. – Peter Sep 17 '14 at 07:52
1 Answers
I am unaware of a way to turn off the screen while recording, or of a way to record while the application is in the background. That does not mean it's not possible, only that I don't know how. It may not be possible now, but become possible in the future. Other answers may explain how to do this.
So I'll list ways to reduce battery consumption while your application is running in the foreground and the screen is on:
Black display. Bright images require a lot more power than dark ones. Depending on the display technology, black pixels require a lot less power than dark pixels. Look at the Lumia Glance feature which can be always on and still requires days to drain the battery.
No animations. Depending on the display technology, redrawing the screen may require more power. In any case, calculating the animation to be drawn on the screen prevents the CPU from sleeping. Having an animation that only updates every second instead of every 15 milliseconds should already be a big improvement.
No wait loops/busy wait. If the CPU needs to wait for something don't use this pattern:
while (true)
{
if (arewethereyet())
break;
}
- Cluster work into batches. The CPU needs to be able to sleep and ideally it needs to be able to sleep for long continuous periods of time. Use a long buffer duration for the microphone and don't fetch the buffer too aggressively.

- 5,608
- 1
- 24
- 43
-
It means, no way is their to continue recording when idle detection mode is enabled or screen gets timeout. – Krrish Sep 17 '14 at 08:52
-
Yes. But you can disable idle detection while your application is in the foreground. – Peter Sep 17 '14 at 08:55
-
But their are events like: public event EventHandler
Obscured which called before going to deactivation state. Is their any possibility to handle using such events? – Krrish Sep 17 '14 at 09:59 -
http://stackoverflow.com/questions/15942952/prevent-automatic-screen-lock-on-windows-phone-8 – Peter Sep 17 '14 at 10:48
-
On which factor we can reduce the memory of recorded file. I am using these parameters: sampleBits,sampleBytes,byteRate and blockalign. – Krrish Sep 17 '14 at 12:54
-
That is an independent question. Please search stackoverflow to find out if it already exists, and create it if it hasn't already been asked by someone else. – Peter Sep 17 '14 at 14:22