locationmanager

Android: Send location data in background periodically (every 30 seconds) and ask server for new data

半世苍凉 提交于 2019-12-04 11:32:40
Scenario: Post to server to get any new data in background every 30 seconds for long period i.e. 12 hours. Location data needs to be sent along with this. Current Implementation; Service Class; Location listener with interval of 30 seconds which sets the longitude & latitude values to two local variables Alarm manager fires pending Intent every 30 seconds to a broadcast receiver. Broadcast receiver starts an IntentService with location variables in the extras. The IntentService http posts location and asks for any new data from server. IntentService send server response back to main service

Android GPS Location Speed Unreliable

泪湿孤枕 提交于 2019-12-04 08:01:06
问题 Writing a GPS logging application~ I'm finding the values returned by the getSpeed() method on Locations reported by LocationManager are massively unreliable. I'm using LocationManager.GPS_PROVIDER , filtering the Locations provided through onLocationChanged for best accuracy. Even at single digit accuracy levels the speed returned is generally ridiculously high. We're talking up to 200 mp/h (yes I know it's logged in metres/sec) when the phone is stationary. I'm testing the same code base on

Change minTime for GPS LocationListener dynamically

自作多情 提交于 2019-12-04 06:29:06
问题 The app that I'm writing uses the GPS location manager service requestLocationUpdates() but I would like to be able to change the min Time and min Distance parameters throughout the program. I initialize the location listener on creation but I can't figure out how to change these parameters or even find out if it's possible to do that. The main purpose for this would be to conserve battery life when the program doesn't need regular position updates. Thanks so much for your help! -Dom 回答1: I'm

Why is locationmanager returning old location fixes with new gettime-timestamp?

瘦欲@ 提交于 2019-12-04 01:24:21
问题 We have an app that upon user action tries to get a location fix. It listens both on GPS and network and has a time/accuracy based decision matrix to determine when to stop listening and what fix to return. We have noticed, on occasion, a very strange behaviour. We use the classic way to see how old the fix is, like so: long age = now - newLocation.getTime(); if(age >= prefs.getLocationMaxAge()){ Log.d(TAG, "location too old."); return; } But sometimes, the location.getTime returned from the

Android: LocationManager constructor's looper

ぃ、小莉子 提交于 2019-12-03 21:03:52
There is the possibility to start retrieving notifications from a LocationManager with the following method: requestLocationUpdates(String provider, long minTime, float minDistance, LocationListener listener, Looper looper) Documentation explains attributes with these words: provider the name of the provider with which to register minTime minimum time interval between location updates, in milliseconds minDistance minimum distance between location updates, in meters listener a LocationListener whose onLocationChanged(Location) method will be called for each location update looper a Looper

addProximityAlert doesn't work as expected

我的梦境 提交于 2019-12-03 17:26:06
ios sdk has great region monitoring functions. I need something like that in android and i think we have two alternatives. Geofencing and LocationManager. Geofencing has really tidy examples and bugs , so i prefered LocationManager. Everyting works fine in LocationManager except one. If you add your current location as ProximityAlert , it immediatly fires "ENTERING" , but it is my current location , it doesnt mean that i entered this region. Because of that , it fires "ENTERING" each time i start my application if i am in region.(Even if i am not moving) How can i solve this problem and fire

What is the meaning of android.location.LocationManager.PASSIVE_PROVIDER?

折月煮酒 提交于 2019-12-03 14:19:34
I understand the meaning of GPS_PROVIDER (locations come from GPS signals) and NETWORK_PROVIDER (locations are determined from cell towers and wireless access points), but I don't understand the meaning of PASSIVE_PROVIDER , despite the definition in the API: A special location provider for receiving locations without actually initiating a location fix. This provider can be used to passively receive location updates when other applications or services request them without actually requesting the locations yourself. This provider will return locations generated by other providers. You can query

current location is always null

本小妞迷上赌 提交于 2019-12-03 11:21:38
问题 I am trying to retrieve my current location on the button click in an editbox using gps or network..i have tried all possible methods which i found in tutorials and older posts....but my location is always null.. i am not getting where i am wrong.? i am testing it on real device having network but no internet/gprs... this is the code which i am using..i tried the same with GPS_PROVIDER as well ..please help me.. protected void showCurrentLocation() { geocoder = new Geocoder(this);

How to stop location manager?

最后都变了- 提交于 2019-12-03 10:24:47
Don't know why, but sometimes LocationManager is still working also after closing application. I call startGPS() in onCreate-Methode in one Activity (only one, let me call it StartActivity). protected void startGPS(){ try { lmanager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); lmanager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this); lmanager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this); } catch(Exception e) { e.printStackTrace(); } } And if this activity will be destroyed (so, when application will be closed), I call endGPS() public

Does anyone know whether the Android addProximityAlert on the LocationManager is battery intensive

笑着哭i 提交于 2019-12-03 09:39:24
I just basically want to add about 20 and sometimes 80 Proximity Alerts with no time expiration with a radius of around 500 meters. Just wondering whether by doing this will suck up the battery real quick? also would it make any difference by reducing the radius? This will definitely eat your battery real quick. You never want to be setting more than a couple of proximity alerts in any case, the use-case you describe isn't really catered for in Proximity Alerts. Proximity Alerts should switch between GPS and Network as required, but in my experience they tend to stick to GPS whenever it's