草庐IT

requestLocationUpdate

全部标签

Android 位置服务不更新 requestLocationUpdates

我有一个获取GPS坐标的简单类GPSListener:publicclassGPSListenerimplementsLocationListener{publicstaticdoublelatitude;publicstaticdoublelongitude;@OverridepublicvoidonLocationChanged(Locationloc){loc.getLatitude();loc.getLongitude();latitude=loc.getLatitude();longitude=loc.getLongitude();Log.d("GPSLISTENER","l

minTime > 0 的 android LocationManager.requestLocationUpdates 未按预期工作

我设置locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,60000,0f,this);它有一个奇怪的行为,每秒调用一次locationChanged,而不是接近1分钟的任何时间。其次,locationChanged每秒被调用一次,持续大约10秒,然后完全停止,gps卫星图标消失,然后仅在屏幕从显示超时返回时再次恢复。怎么了?我目前使用的是android1.5。 最佳答案 minTime(60000)只是一个提示,不能保证您的位置监听器会以精确的1分

android - addProximityAlert 不起作用(requestLocationUpdates 也不起作用)- Android

当手机靠近某个位置时,我正在尝试获取和更新。我都尝试过使用addProximityAlert和requestLocationUpdatesLocationManagerlm=(LocationManager)getSystemService(Context.LOCATION_SERVICE);Locationl=lm.getLastKnownLocation("gps");Intentintent=newIntent("eu.mauriziopz.gps.ProximityAlert");PendingIntentpIntent=PendingIntent.getActivity(th

android - requestLocationUpdates 不会在 Android 中按时间间隔更新

我的问题是我的服务实现了LocationListener,似乎每500毫秒接收一次GPS更新。无论我在requestLocationUpdates函数中输入什么minTime。我的代码fragment:publicclassLocationServiceextendsServiceimplementsLocationListener{LocationManagerlocMan;@OverridepublicintonStartCommand(Intentintent,intflags,intstartId){locMan=(LocationManager)getSystemServic

android - LocationManager requestLocationUpdates 不起作用

我正在尝试使用LocationManager和LocationListener在android中获取当前位置,如http://developer.android.com/guide/topics/location/obtaining-user-location.html中所述但是,永远不会调用LocationListener的onLocationChanged方法。我使用了一部真正的Android手机/也使用了模拟器,并使用telnet更改了模拟位置,如上面的链接所述。这是我的代码:publicclassMyActivityextendsActivity{@Overridepublic

android - 如何在调用 requestLocationUpdates 后更改 FusedLocationApi 更新间隔

我正在使用LocationServices.FusedLocationApi以给定的时间间隔获取位置更新,这是在传递给requestLocationUpdates的LocationRequest对象上设置的:mLocationRequest=newLocationRequest();mLocationRequest.setInterval(30000);LocationServices.FusedLocationApi.requestLocationUpdates(mGoogleApiClient,mLocationRequest,this);我需要更改监听器开始接收位置更新后的间隔值

android - requestLocationUpdates() 在单独的线程中

我需要将requestLocationUpdates()放在一个单独的线程中,以免它阻塞我应用程序的其余部分(它将在大部分时间运行)。最好的方法是什么? 最佳答案 当您调用requestLocationUpdates()时,这仅表示您希望在用户位置更改时被回调。此调用不会花费大量时间,并且可以在主线程上进行。当用户的位置发生变化时(并根据您传递给requestLocationUpdates()的条件),您的监听器将通过onLocationChanged()回调或通过通知>Intent(取决于您传递给requestLocationUp

android - Android 中的 requestLocationUpdates 间隔

我尝试为函数onLocationChanged获取正确的更新速度,这是我的类(class):publicclassLocationServiceextendsServiceimplementsLocationListener{将minTime设置为6000没有帮助,它会不断更新,我做错了什么?publicvoidrequestLocationUpdates(Stringprovider,longminTime,floatminDistance,LocationListenerlistener,Looperlooper){问候 最佳答案

android - requestLocationUpdates 中的更新间隔

如何更新时间和距离间隔,或者以不同的间隔再次调用requestLocationUpdates?我的代码:LocationManagerlocationManager=(LocationManager)activityObject.getSystemService(Context.LOCATION_SERVICE);cll=newCheckinLocationListener();LocationProvidergps=locationManager.getProvider(LocationManager.GPS_PROVIDER);//GPSlocationManager.reques

android - 位置管理器 requestLocationUpdates 只调用一次

我正在调用该方法并期望位置更新多次:locationManager.requestLocationUpdates("gps",0,0,loc_listener);我的loc_listener定义为:LocationListenerloc_listener=newLocationListener(){privatefinalStringTAG="xoxoxo.LocationListener";publicvoidonLocationChanged(Locationl){IntentlocationAlert=newIntent("xoxoxo.LOCATION_CHANGED").pu