English 中文(简体)
iPhone app running while screen locked
原标题:

Here is something I am trying desperately to get to work:

I have an app that polls the GPS module in specified intervals and then sends out coords out to a server using Unix calls such as write(); It works fine when the app is active, but once the screen locks itself, reporting stops.

I have found this: [UIApplication sharedApplication].idleTimerDisabled = YES; This does keep the app alive, but also rapidly discharges the battery. I came across other apps that stream music even when the screen is locked (non-Apple apps) and thus I figured there has to be a way to keep the GPS data stream alive.

Can anyone assist? Thank you!

问题回答

Have a look at this:

http://marcopeluso.com/2009/08/23/how-to-prevent-iphone-from-deep-sleeping/

It s a drop in piece of code used to disable deep sleep. Your screen can still shut off while your application continues to run in the background.

You have to leave the screen unlocked. But that does not mean you have to leave GPS enabled. You can shut down the GPS monitor and awaken it every few minutes, that and an all-black "screensaver" that comes on after a minute should cut down on the drain quite a lot.

If your application plays (or records) sound, even if you play silence, it would continue running even when the screen is locked. So you might want to try to play silence via audio queue services to keep your app running.

Note that I don t know any GPS-related specifics with regards to this question. Another commenter says that GPS is specifically prohibited from running when the screen is locked (which might be a sensible decision on Apple s side, given the possible privacy issues). I can t advise whether that s true or not.

I am not 100% sure, but I think I heard somewhere that the GPS module only works when the screen is not locked. (Unless you have a jailbroken phone of course...)

I think I read this when I was downloading a running application that kept track of my location while I was out running. The app had its own "lock screen" that I had to have up for it to work, which drained the battery quite fast. If I were to lock the screen normally then unlock it again, it would have to reacquire my location.

I don t think its possible (its something I ve wanted to be able to do in the past). I know for instance that the safari browser, which can access GPS, doesn t do so when the screen is locked, although that could be by design rather than limitation.





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签