Questions tagged [locationmanager]

The LocationManager class in Android provides access to the system location services. These services allow applications to obtain periodic updates of the device's geographical location, or to fire an application-specified Intent when the device enters the proximity of a given geographical location.

The LocationManager class in Android SDK provides access to the system location services. These services allow applications to obtain periodic updates of the device's geographical location, or to fire an application-specified Intent when the device enters the proximity of a given geographical location.

1041 questions
98
votes
6 answers

Android check permission for LocationManager

I'm trying to get the GPS coordinates to display when I click a button in my activity layout. The following is the method that gets called when I click the button: public void getLocation(View view) { TextView tv = (TextView)…
user
  • 1,251
  • 2
  • 10
  • 11
79
votes
4 answers

Difference between LocationRequest setInterval (long millis) and LocationRequest setFastestInterval (long millis)

I am writing my own background location updates for interval of every 5 minutes in android. I would like to know the difference between setInterval and setFastestInterval When I setInterval to 5 mins and setFastestInterval to 2 mins. The location…
TheDevMan
  • 5,656
  • 12
  • 67
  • 133
74
votes
14 answers

OnLocationChanged callback is never called

I am trying to get the users current location using the LocationManager. I have done a lot of research and can't seem to find anyone with the same problem. The OnLocationChanged callback never seems to be called. Below is my various code and the…
smitt04
  • 2,890
  • 2
  • 25
  • 30
48
votes
5 answers

NETWORK_PROVIDER not providing updated locations

LocationManager locationManager = (LocationManager)getApp().getSystemService(Context.LOCATION_SERVICE); //getApp() returns my Application object locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER , 1, 1,…
hersh
  • 589
  • 1
  • 4
  • 6
42
votes
8 answers

LocationListener of NETWORK_PROVIDER is enabled but , onLocationChanged is never called

I am developing an application that gets position of the cell phone all day long in 6 and 6 minutes in a service, it works fine but sometimes the method OnLocationChanged of the Network provider listener stop to being called, and I don't know…
37
votes
2 answers

GPS Android - get positioning only once

Is there a way to access the GPS once instead of having a looper that constantly checks for location updates? In my scenario all I'm interested in is finding the current co-ordinates and not a continuous connection with the GPS satellite. Does…
progdoc
  • 579
  • 3
  • 11
  • 24
34
votes
6 answers

How to stop location manager?

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 { …
Tima
  • 12,040
  • 22
  • 74
  • 121
27
votes
4 answers

Getting user location every n minutes after app goes to background

I am trying to implement the suggestions given in this post. Unfortunately the steps are not clear to me. I tried implementing those suggestions, but the backgroundTimeRemaining continues to decrease even after I start and stop locationServices. …
scurioni
  • 2,344
  • 1
  • 16
  • 14
26
votes
4 answers

Call requires permissions that may be rejected by user

I am trying to make an application that sends location updates of a user after every five minutes. I suppose my code is working just fine but i get an error regarding the permissions that are being used by the application. I am pretty sure that i…
Aman Verma
  • 269
  • 1
  • 3
  • 4
26
votes
4 answers

How does getSystemService() work exactly?

At first glance in the code below the mLocationManager object should go out of scope after onCreate(...) is finished, and the expected behaviour is that onLocationChanged is never called or called a few times until the object is garbage collected.…
Vasile Jureschi
  • 2,009
  • 1
  • 17
  • 17
22
votes
7 answers

onLocationChanged() never called

I am writing a code that brings current location but it is not giving me the location because it never calls onLocationChanged() .Is there any way to find the location. mobileLocation is coming 0 for this case, so the execution goes to the else…
abhishek ameta
  • 2,046
  • 7
  • 25
  • 35
16
votes
2 answers

How to get a reference to LocationManager inside a Fragment

I have a class that extends Fragment and implements LocationListener. When I write LocationManager myLocalManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); I get an compile time error because the method getSystemService is not…
malcolm the4
  • 307
  • 2
  • 5
  • 15
14
votes
7 answers

How to get last known location for Location manager in Android?

I am using simple location manager object to get lastKnownLocation() of device but getting null object in return can any one tell me why ? Code : public Location getLocation() { LocationManager locationManager = (LocationManager)…
Aditi K
  • 1,444
  • 5
  • 19
  • 42
13
votes
3 answers

How to? Listen for Location Setting being turned ON (Android App)

So I've spent the past few weeks working on my Android App and looking into the best way of implementing what I need to do, but still can't quite get it right.. Any/all help is greatly appreciated, as I am still getting the hang of…
Ender87
  • 161
  • 1
  • 2
  • 8
13
votes
6 answers

Get current location name of user without using gps or internet but by using Network_Provider in android

This question is directly related to the same prevailing stackoverflow question at "Android: get current location of user without using gps or internet" where the accepted answer is actually not answering the question. I should be able to get the…
Samitha Chathuranga
  • 1,536
  • 4
  • 25
  • 56
1
2 3
69 70