设置好,LocationSensor.active := true。
当按home键或黑屏后,程序将立马挂起。LocationSensorLocationChanged事件也不会响应。
有人说要两三秒才挂起,到我这却是立马,不知为啥。
在网上知道的解决方案:http://www.fmxexpress.com/learn-to-use-the-location-sensor-in-the-background-with-firemonkey-in-delphi-10-berlin-on-ios/
经测试后,发现它并不能完全做到后台一直运行。一般运行十来分钟就停止了。
具体解决方案:在上述网址基础(FLocater.setAllowsBackgroundLocationUpdates(True);)上,还需要加上
FLocater.setPausesLocationUpdatesAutomatically(False);
也就是
if TOSVersion.Check(9) and (FLocater <> nil) then
原文:http://www.cnblogs.com/dannylee/p/7149941.html