views:

255

answers:

4

I'm trying to read the accelerometer for a longer period of time (between one and two hours).

However, when the iPhone goes to sleep and locks, the reading of the accelerometer readout is paused.

My setInterval timer seems to be running fine though. I can also play sounds.

I see two solutions

a) Find a way to read the accelerometer while locked b) Find a way to prevent the lock

I'm using Titanium with JavaScript.

+2  A: 

See docs for [UIApplication sharedApplication].idleTimerDisabled = YES

Nimrod
Yes, found that one. However, I don't think it's available in Titanium?
Morten J
It is a pretty useful feature. Perhaps you could file a feature request with the Titanium developers.
Alex Reynolds
Good point, thanks. Done.
Morten J
Is there no way to create platform-specific extensions for it? I don't know anything about titanium. I do know that it's possible to expose objects to the javascript interpreter in UIWebView which might provide some roundabout way to do things.
Nimrod
I don't think there is. I know there is for PhoneGap, a similar framework. However, the people making Titanium got back to me and said they would include it in the next release.
Morten J
There is a module system for extending Titanium, but with this being included in 0.9 it is probably better to just wait. (Of course, the module system is getting easier to work with in 0.9 as well)
Jackson Miller
A: 

If it's actually locking (and not just sleeping) that causes the lock: Settings -> General -> Auto-Lock -> Never

Stephen Canon
Good point. However, I must assume that most users will have this turned on. If there's an Exchange account installed, it can't even be turned off
Morten J
+1  A: 

Appcelerator will include this in version 0.9

Morten J
+3  A: 

In 0.9+ you can do the following:

Titanium.App.idleTimerDisabled = true;
jhaynie