Enable iPhone accelerometer while screen is locked
Asked Answered
M

2

9

So apparently it is possible to keep the processor going processing stuff while the screen is locked, as indicated here:

Running IPhone apps while in sleep mode

However, after testing with the example code, UIAccelerometer will just stop giving value as soon as the device is locked pronto. Is there a way to force otherwise?

Mcroberts answered 27/3, 2010 at 13:27 Comment(1)
Are you using the timer that plays a silent audio file trick?South
N
1

There was a bug in iPhone OS prior to 3.1.2 that caused the accelerometer to stop returning values as soon as the screen was blanked. You may be running into this same issue. I filed a bug with Apple about it and they fixed it in 3.1.2.

One trick I use in an app is to enable the proximity sensor. This allows my app to continue running, but if the user puts their phone in their pocket or otherwise trips the sensor, the screen turns off and doesn't consume power. Meanwhile, my app is still running and (3.1.2 or later) the accelerometer continues sending updates.

Nica answered 29/3, 2010 at 15:20 Comment(1)
Whoa thanks, that would be a nice trick if it works -- gonna give it a try. Too bad about the iPod owners though.Mcroberts
S
0

I haven't tried this but if you've tired the workaround and it didn't work then it's possible that Apple patched out the hack. The link that gives the work around is from Sept 09 and we've had at least one OS update since then.

South answered 27/3, 2010 at 13:59 Comment(3)
Not something that apple likes huh.. I guess we'll just have to somehow minimise battery usage..Mcroberts
Apple doesn't like anything that takes control aways from the user or which might deceive the user. I think you may have a design problem if you are planning on creating the appearance that the iPhone is asleep when it is not. Users would think it turned off and would accidentally run the phone flat. I would add that you can cut power use enormously by displaying a simple black view with a little bit of text indicating the operation. You should always have an indication of what the device is doing so the user can manage it.South
That's true huh.. black screen. I did wish there was a 'turn of screen to preserve energy' option but this is probably the best we'll get eh.Mcroberts

© 2022 - 2024 — McMap. All rights reserved.