检索最后已知的位置,当智能手机被关闭很长一段时间 [英] Retrieve the Last Known Location when the smartphone was turned off a long time

查看:87
本文介绍了检索最后已知的位置,当智能手机被关闭很长一段时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一个Android项目和应用程序需要的GPS坐标的工作。

因此​​,一个长时间的睡眠后,code的线下给我空当我试图获取坐标

 的LocationManager =(的LocationManager)getApplicationContext()getSystemService(LOCATION_SERVICE)。
位置_lastLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

因此​​,为了得到他们,我已经开始谷歌地图这是一个有点disapointing。我已经读了很多线程,但有人真的很有帮助。我使用的三星S2 S3 但是我也读到,原因是它停留在循环试图重新启动itslef本地服务的错误。


  

是任何人都知道我怎么能算出这个?



解决方案

有关设备的地理位置,您可以使用许多供应商,如的 LocationManager.GPS_PROVIDER ,的 LocationManager.NETWORK_PROVIDER LocationManager.PASSIVE_PROVIDER

您会发现在位选择战略方针

I'm working on an Android project and the application needs the GPS coordinates to work.

So after a long sleep, the line of code below give me null when I try to get the coordinates

locationManager = (LocationManager)getApplicationContext().getSystemService(LOCATION_SERVICE);
Location _lastLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

So to get them, I've to start Google Maps which is a little bit disapointing . I already read a lot of threads but anyone really helpful. I'm using a Samsung S2 and a S3 but I also read that the cause is a bug in the native service which stuck in a loop trying to restart itslef.

Is anybody know how can I figure this out?

解决方案

For Geolocation of your device, you can use many providers, such as LocationManager.GPS_PROVIDER, LocationManager.NETWORK_PROVIDER and LocationManager.PASSIVE_PROVIDER.

You will find more infos in Location Strategies guideline

这篇关于检索最后已知的位置,当智能手机被关闭很长一段时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆