Questions tagged [android-location]

android-location refers to the location API provided by the Android framework.

References

1355 questions
10
votes
1 answer

Foreground service vs WorkManager for location tracking

Let's say I want to build an app which requests current location periodically (e.g., every 10 minutes, this number should be configurable) and submits to a server. I'm aware that Foreground Service and WorkManager are normally suggested for this…
10
votes
4 answers

How does ACCESS_BACKGROUND_LOCATION introduced in Android Q affect Geofence APIs?

In order to use the Geofence API the user has to give the app ACCESS_FINE_LOCATION. This location is considered to be dangerous and can be revoked at any time; once this permission is revoked, the app can not request the geofence updates. How does…
aga
  • 27,954
  • 13
  • 86
  • 121
10
votes
1 answer

How can I change the interval of LocationRequest

I set my application to get location notification every 5 seconds. mLocationRequest = LocationRequest.create(); mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY); mLocationRequest.setInterval(5000); …
DuduArbel
  • 1,100
  • 1
  • 12
  • 25
10
votes
2 answers

Android, Location Request, set expiration duration doesn't work

I'm using new API of location which had been introduced in I/O 2013. It works fine and I have no problem with its results. My problem is when I set setExpirationDuration(WHATEVER_MILLIS) to whatever millis however it works for one minutes. This is…
Hesam
  • 52,260
  • 74
  • 224
  • 365
10
votes
2 answers

SecurityException when calling getLastKnownLocation

We've been getting reports of crashes on some devices when a user opens an Activity that calls the location manager's getLastKnownLocation method. We've requested all the required permissions in our application manifest:
twaddington
  • 11,607
  • 5
  • 35
  • 46
10
votes
4 answers

Is it possible to get a notification when any location provider is enabled/disabled and ascertain what action occurred?

I wish to receive a notification when the user enables or disables either Network or GPS locations, and importantly I wish to know which one they have changed and how. I have a broadcast receiver for the android.location.PROVIDERS_CHANGED broadcast…
Steve Weet
  • 28,126
  • 11
  • 70
  • 86
9
votes
1 answer

Android 10 (Q) ACCESS_BACKGROUND_LOCATION permission

I need the user to check and set permission to ACCESS_BACKGROUND_LOCATION ("Allow all the time") without the option to "Allow only while using the app". My GPS Tracking app needs to continue accessing location even when the application is…
Chris King
  • 225
  • 1
  • 4
  • 14
9
votes
3 answers

How to time out GPS signal acquisition

My app uses the LocationListener to get one position fix and then removeUpdates() once every minute (to conserve battery). The problem is that if a user moves inside then it will perpetually look for a signal, burning more battery. I was wondering…
GPSmaster
  • 844
  • 3
  • 15
  • 31
9
votes
3 answers

Android : LocationManager dynamically adjust minTime/minDistance thresholds

This is the way I listen for GPS location updates (using LocationManager and a LocationListener): locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); listener = new MyLocationistener(); //…
Guido
  • 46,642
  • 28
  • 120
  • 174
9
votes
1 answer

sending extra to requestLocationUpdates intentService breaks location updates

I'm having trouble sending a string extra with my PendingIntent that I pass to LocationServices.FusedLocationApi.requestLocationUpdates(GoogleApiClient client, LocationRequest request, PendingIntent callbackIntent). It appears that the username…
9
votes
3 answers

can not setInterval in onLocationChanged

I am trying the 'LocationUpdates' sample from http://developer.android.com/training/location/receive-location-updates.html . This application gets and prints location notifications. I am trying to change the interval of the location updates…
DuduArbel
  • 1,100
  • 1
  • 12
  • 25
9
votes
1 answer

Do I need to request location updates when using Fused location Geofences?

I have successfully implemented location geofencing using the Android Developers documentation. The problem I am having is that the geofence events are not always reliable. Sometimes they trigger as soon as I'm at the location, sometimes they take a…
Nick
  • 748
  • 1
  • 5
  • 23
8
votes
2 answers

Android: App is rejected by Google because of background location

I have issues with my app recently, when it is out of nowhere rejected by Google Play because they found that I'm using background location. But in fact I'm not using this feature. I have only ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION…
8
votes
2 answers

How to write Espresso Tests which are mocking GPS locations and use them in Google Testlab?

I recorded an espresso test with Espresso Recorder. I want to test some location changes in my app. Currently I'm mocking the location with this code: LocationManager lm = (LocationManager)…
8
votes
2 answers

Unable to detect User activity transition , using broadcast receivers

I have used the Activity Transition API launched by Google recently to detect when a User gets in and out of the vehicle. Below is the code I am using to achieve the same. val intent = Intent(context, ActivityTransitionReceiver::class.java) val…