Questions tagged [android-location]

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

References

1355 questions
16
votes
3 answers

What is the difference between shouldShowRequestPermissionRationale and requestPermissions?

I am building an app that requires user location. I am following the Android training documentation from here which says: shouldShowRequestPermissionRationale return the boolean indicating whether or not we should show UI with rationale for…
Sumit Jha
  • 2,095
  • 2
  • 21
  • 36
16
votes
3 answers

Are there any advantages of using FusedLocationProviderApi over LocationManager?

Earlier to get user current location I have used LocationManager: LocationManager locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE); if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { …
15
votes
4 answers

Android getMaxAddressLineIndex returns 0 for line 1

For some reason the implementation of getMaxAddressLineIndex has recently changed. Now this method returns 0 for line 1. I have an existing code, which used to work: i
codebased
  • 6,945
  • 9
  • 50
  • 84
15
votes
3 answers

Which is a higher accuracy criteria: ACCURACY_HIGH or ACCURACY_FINE?

In the Criteria class, there are two constants, ACCURACY_HIGH and ACCURACY_FINE, which are apparently used to require the LocationManager to return higher accuracy location updates. Here is what the documentation says about each of these…
robguinness
  • 16,266
  • 14
  • 55
  • 65
15
votes
3 answers

Why does my OnLocationChanged() never get called?

What I am trying to do: I am trying to develop an app that only requires the user's location at the start of one activity. So only when the user is within the activity, the location gets updated either by network or GPS. Accordingly, the user may…
Sibbs Gambling
  • 19,274
  • 42
  • 103
  • 174
15
votes
4 answers

How to extend android class which implements Parcelable interface?

First of all i have check this answer. What i am trying to do is extending Location class calling it LocationPlus which has some member variables. functionality i am trying to achieve is pass the object of LocationPlus class from one activity to…
Akram
  • 7,548
  • 8
  • 45
  • 72
15
votes
3 answers

How to get the coarse location using Wifi or GSM or GPS, whichever is available?

My app only needs a coarse location service when started up. In detail, I need the app's rough location so as to provide the users with the shop info nearby. The location does NOT need to be updated constantly. In addition, coarse localization will…
Sibbs Gambling
  • 19,274
  • 42
  • 103
  • 174
14
votes
2 answers

fusedLocationProviderClient.lastLocation.addOnSuccessListener always null

I just updated my Location API to use FusedLocationProviderClient but I am having this issue, when I turn off and on the GPS, I am always getting null location: val fusedLocationProviderClient = …
14
votes
5 answers

How to ask user to enable GPS at the launch of application?

private void turnGPSOn(){ String provider = Settings.Secure.getString(getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED); if(!provider.contains("gps")){ //if gps is disabled final Intent poke = new Intent(); …
Mishu
  • 269
  • 1
  • 3
  • 15
14
votes
2 answers

Android: Drag map while keeping marker at the center

I am currently getting Current Location of device (lat,lng) in MapActivity. Now , I want to let the user move the map, while keeping the marker at the center. This means that whenever the map is moved, current location will be updated. (Right?) I…
AIS
  • 297
  • 1
  • 4
  • 16
14
votes
6 answers

GeoCoder Service not Available

GeoCoder Service not Available I'm using the GeoCoder to get an AddressLocation. Unfortunately the method fires an IOException saying: "Service not Available". This StackOverFlow thread explains what is going on because I tested it thoroughly (user…
13
votes
2 answers

How can we listen for location permission changes in Android (without triggering a permission request)?

Is it even possible? I would like to be able to create a listener which will be notified about location permission changes (whether the app triggers them or not). As far as I can see, there are methods for getting the current permission status and…
Rupert
  • 2,097
  • 19
  • 28
13
votes
4 answers

FusedLocationProviderClient.removeLocationUpdates always returns failure

I have an activity that extends a base class called LocationAwareActivity all this LocationAwareActivity activity does is creates a location service client LocationServices.getFusedLocationProviderClient and listens to location updates. Source for…
Subodh Nijsure
  • 3,305
  • 5
  • 26
  • 45
13
votes
6 answers

Ask user to turn on Location

How can I prompt the user to turn on Location? The app is supposed to filter a list of locations with the current location of the user. If the user has the Location service turned off, the app should prompt the user asking for the Location to be…
13
votes
1 answer

Geofences not working when app is killed

I know similar questions have been asked before but answers were not perfect. I created an app with geofences using the sample code from android developer website. I did not use any shared preferences to store geofences as I am not removing the…
Neanderthal
  • 937
  • 2
  • 9
  • 25
1 2
3
90 91