android-location

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

社会主义新天地 提交于 2019-12-01 05:21:42
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 OS has an age of perhaps 15-20 seconds, according to the returned timestamp, although we can tell for

Get location (coordinates) periodically without dramatically increase battery consumption

江枫思渺然 提交于 2019-12-01 04:43:45
I'm developing an Android application; this App needs to send periodically (every 10 minutes) the current position (coordenates) to a web service. But ... I'm a little confused about the more correct way (and friendlier to the device battery) to do that. I read this answer and her method _getLocation() looks well; but I don't know whether that method could get the availability of the location I need; total availability... I would like, if the location is not available using GSM / WIFI, application choose the GPS method. Is that what makes this method? private void _getLocation() { // Get the

Get location (coordinates) periodically without dramatically increase battery consumption

牧云@^-^@ 提交于 2019-12-01 02:29:58
问题 I'm developing an Android application; this App needs to send periodically (every 10 minutes) the current position (coordenates) to a web service. But ... I'm a little confused about the more correct way (and friendlier to the device battery) to do that. I read this answer and her method _getLocation() looks well; but I don't know whether that method could get the availability of the location I need; total availability... I would like, if the location is not available using GSM / WIFI,

Android: How to make user create geofence for another tracked users?

时光毁灭记忆、已成空白 提交于 2019-12-01 01:16:12
How to implement Geofence for tracking another users? I am developing an application which will track family members, and I want to implement Geofence feature which will enable user to do for ex: user A will track user B user A will determine the geofence area and when user B will enter this geofence user A will get a notification I retreived the location of user B every 10 minutes and I want to create Geofence for user B which will notify user A when user B enter the geofence area I try to use google Geofence like this code : mGeofenceList.add(new Geofence.Builder() // Set the request ID of

How to get Location with Wifi in Android?

三世轮回 提交于 2019-11-30 21:25:13
I Want get location with Wifi and work in Google map, and it's not work for me but Gps is okay and not problem. my code: locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); if (locationManager != null) { boolean gpsIsEnabled = locationManager .isProviderEnabled(LocationManager.GPS_PROVIDER); boolean networkIsEnabled = locationManager .isProviderEnabled(LocationManager.NETWORK_PROVIDER); if (gpsIsEnabled) { locationManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 5000L, 10F, (android.location.LocationListener) this); } else if (networkIsEnabled) {

Google Location Services Vs Android Location Services

一笑奈何 提交于 2019-11-30 19:50:09
As we know we have two alternates for making our applicaiton location aware Either we use Google’s Location Services API (part of Google Play services) or we use Androids Location API . The problem I have here is that using the Google's services , we have to use interface com.google.android.gms.location.LocationListener that provides us with location updates. However unlike the android.location.LocationListener, the google's version doesnt' provides us the state of the location provider (gps or internet). we have the following methods in the Androids Location Listener abstract void

Android LocationRequest: get a callback when request expires

删除回忆录丶 提交于 2019-11-30 17:33:48
im wonder how to catch event or what ever when my LocationReqest expired, heres code then i call it mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); mLocationRequest.setExpirationDuration(500); mLocationRequest.setNumUpdates(1); mLocationClient.requestLocationUpdates(mLocationRequest, this); now i need to get know that my LocationRequest was break, ty for help :) edit i thought i could catch it in public void onLocationChanged(Location location) { //something is here } but its doesnt work :( edit2 i partial solved it by adding

requestLocationUpdates() in separate Thread

假装没事ソ 提交于 2019-11-30 15:28:59
问题 I need requestLocationUpdates() to be in a separate Thread, in order to not have it blocking the rest of my application (it will run most of the time). What is the best way to do it? 回答1: When you call requestLocationUpdates() this just indicates that you want to be called back when the user's location changes. This call doesn't take a significant amount of time and can be made on the main thread. When the user's location changes (and based on the criteria you pass to requestLocationUpdates()

requestLocationUpdates() in separate Thread

故事扮演 提交于 2019-11-30 14:35:45
I need requestLocationUpdates() to be in a separate Thread, in order to not have it blocking the rest of my application (it will run most of the time). What is the best way to do it? When you call requestLocationUpdates() this just indicates that you want to be called back when the user's location changes. This call doesn't take a significant amount of time and can be made on the main thread. When the user's location changes (and based on the criteria you pass to requestLocationUpdates() ) your listener will be called back via onLocationChanged() or notified via Intent (depending on which

share location with share intent Activity

人走茶凉 提交于 2019-11-30 13:21:12
问题 I need to share location from my app using the share intent activity, I have gone through some examples and know how to implement share intent. However I am stuck at setType. I need my application to share location details as well the users location on a map. By the way i copied a users code with a very similar question"no offence" Any assistance would be really appreciated. Intent intent1 = new Intent(Intent.ACTION_SEND); intent1.setType("text/plain"); intent1.putExtra(Intent.EXTRA_TEXT,