草庐IT

locManager

全部标签

iphone - 当我的应用程序进入后台模式时,如何更新位置管理器和计时器?

我有一个计时器,它显示用户锻炼的NSTime。当我的应用进入后台模式时,位置管理器和计时器停止更新。当我的应用程序处于后台模式时,如何让它们更新?我有一个名为RunViewController的View,它有开始按钮。当用户单击该按钮时,计时器和位置管理器启动。代码是:-(void)startRun{timeSec=0;timeMin=0;timeHour=0;NSString*timeNow=[NSStringstringWithFormat:@"%02d:%02d:%02d",timeHour,timeMin,timeSec];//DisplayonyourlabellblTime

ios - 试图从 UIImagePickerController 中提取 GPS 元数据,但 NSLog 显示为空

我正在尝试使用UIImagePickerController从图像的元数据中收集GPS信息。这是我的代码示例:NSDictionary*imageMetadata=[infoobjectForKey:UIImagePickerControllerMediaMetadata];NSLog(@"WorkingMETA:%@",imageMetadata);CGDataProviderRefdataProvider=CGImageGetDataProvider(originalImage.CGImage);CFDataRefdata=CGDataProviderCopyData(dataPr

ios - 无法在 iOS 8 中检测到 iBeacon

我已经学习了来自AppCoda的在线教程和Devfright创建iBeacon检测应用程序。我使用的是来自estimote的iBeacon,这是一台装有iOS8的iPad3。该应用程序根本检测不到我的iBeacon,而它却被其他iBeacon应用程序检测到了。我不明白我的代码中遗漏了什么或做错了什么。这是我的.h文件:#import#import@interfaceViewController:UIViewController@property(nonatomic,strong)CLBeaconRegion*beaconRegion;@property(nonatomic,strong

Android 如何在 LocationManager 中获取高度。我总是归零

我正在尝试通过location.getAltitude()方法获取当前海拔高度。但它总是返回零。我应该怎么做才能获得当前的高度值。但正确获取经度和纬度。请给我建议。我在谷歌中搜索并计算出一些样本,但所有样本都只返回零。我用过的代码:在创建时我调用了=getMyCurrentLocation();这个方法。voidgetMyCurrentLocation(){LocationManagerlocManager=(LocationManager)getSystemService(Context.LOCATION_SERVICE);LocationListenerlocListener=ne

android - onLocationChanged 只调用一次,不刷新

出于某种原因,我制作了一个小型gps应用程序onLocationChanged不刷新,它只在应用程序启动时运行一次。这是我的代码:publicBackgroundLocationService(){super("myintentservice");locManager=(LocationManager)context.getSystemService(Context.LOCATION_SERVICE);Criteriacrt=newCriteria();crt.setAccuracy(Criteria.ACCURACY_FINE);StringbestProvider=locManag

android - 根据 gps 状态 android 可互换的网络和 GPS 位置提供者

如果有人能帮助我,我将不胜感激。我需要在我的应用程序中有一个准确的位置跟踪器,我希望它像这样。它找到了有网络的人的第一个位置,同时我开始请求GPS定位。当gps给我一个位置时,我不想再听网络位置了。之后我只想从网络请求一个位置,并且只有在Gps不固定的情况下(不能给我一个位置)。当Gps再次固定时,我想停止收听网络,这是我想实现的循环,因为GPS更准确,我想将网络定位作为备份。我看过这篇文章,但我似乎无法理解如何使其适应我的需要,HowcanIcheckthecurrentstatusoftheGPSreceiver?需要想法,提前感谢Stackoverflow社区。

ios - iOS 磁航向示例代码

谁能给我提供一个简短的片段,让我返回iPhone的磁航向?我不要Objective-C。我在Swift中需要它。到目前为止我已经写了这些行,但它没有返回任何值:letlocManager=CLLocationManager()locManager.desiredAccuracy=kCLLocationAccuracyBestlocManager.requestWhenInUseAuthorization()locManager.startUpdatingLocation()locManager.startUpdatingHeading()locManager.headingOrient

ios - Swift:获取用户的位置坐标作为纬度和经度?

当用户按下按钮时,我想将他们的纬度和经度存储为变量。我不明白如何使用Coordinate2D方法。而不是println(locManager.location)我想打印(或存储为单独的变量)纬度和经度。请帮忙。我的代码如下。classViewController:UIViewController,CLLocationManagerDelegate{varlocManager=CLLocationManager()@IBOutletvarpushToParkText:UILabel!@IBActionfunccarButton(sender:UIButton){println(locMa

ios - 如何将纬度和经度传递给另一个函数 - swift location

我在将纬度和经度传递给一个函数时遇到问题,我正在构建apiurl以获取一些天气数据。我知道在调用天气函数之前我缺少调用位置函数的东西。基本上我的想法是先获取位置并将纬度和经度存储在一些变量中,然后调用我在其中使用这些值的天气函数。我已经为我的思路提供了评论。如有任何帮助,我们将不胜感激。谢谢你。importUIKitimportCoreLocationclassViewController:UIViewController,CLLocationManagerDelegate{varlocManager=CLLocationManager()//createdthesetostoreth