locationmanager

Why isn't Android's onProviderEnabled() method being called?

怎甘沉沦 提交于 2019-11-29 13:32:13
My Android app has two location listeners, one for fine and one for coarse listening. I want to be able to detect when the user turns their location services off and on. Whenever I turn my phones GPS or network location services OFF the onProviderDisabled method is called as expected. When I turn GPS or network services ON the onProviderEnabled is never called! I have put the code for one of the listeners below.... Update... I have discovered that the problem is related to unregistering the listeners in onPause. When I remove the code "locationManager.removeUpdates(myFineLocationListener);"

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

岁酱吖の 提交于 2019-11-29 12:43:52
问题 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 current location name (eg:city name, village name) of the device via network provider not with GPS or internet. Following is the accepted answer in that question. (The following code parts should be included in the onCreate() method) // Acquire a

LocationManager and jumping coordinates

房东的猫 提交于 2019-11-29 08:59:45
Take a look at this image. You see that some how LocationManager gives weird coordinates. It looks like they jump. But at the same time native google map app display correct location of the moving device. I tested app with 3 different smartphones under Android 7.0.0 and 7.1.1 and get the same result more or less. Please help me check my code to see which settings it is missing still. Thank you! import android.app.Service; import android.content.Context; import android.content.Intent; import android.location.Location; import android.location.LocationManager; import android.net

Get current location during app launch

不问归期 提交于 2019-11-29 02:09:44
Good Day! I am working on an android app which monitors user location. I am using LocationManager to get users location, using the following method public void onLocationChanged(Location theLocation) {} Through the above method, whenever there was a user movement, I am receiving location coordinates. But, now I am planning to get user's location immediately after their app login. Is there any way through LocationManager through which I can manually get the location coordinates after my app launch? Use this technique : LocationManager locManager = (LocationManager)getSystemService(Context

Getting the current GPS location on Android

假装没事ソ 提交于 2019-11-28 19:58:12
I'm trying to get the user's current location via GPS capability, Wrote a simple class that implements LocationListener public class LocationManagerHelper implements LocationListener { private static double latitude; private static double longitude; @Override public void onLocationChanged(Location loc) { latitude = loc.getLatitude(); longitude = loc.getLongitude(); } @Override public void onProviderDisabled(String provider) { } @Override public void onProviderEnabled(String provider) { } @Override public void onStatusChanged(String provider, int status, Bundle extras) { // TODO Auto-generated

Asking for permissions while using LocationManager

半城伤御伤魂 提交于 2019-11-28 14:10:43
I've just started with Android programming and so far, I've just messed a little bit around buttons, textviews and some activities, but I would like to begin with services and GPS locations. In order to practise a little bit, I'm building a simple app that just shows the coordinates of the user. I've created my own service class with some methods, but whenever I try to implement the following one, my app crashes: @TargetApi(23) public Location getLocation(){ try{ locationManager = (LocationManager)this.ctx.getSystemService(LOCATION_SERVICE); gpsActivado = locationManager.isProviderEnabled

onLocationChanged is not called automatically

一个人想着一个人 提交于 2019-11-28 10:02:44
I have a problem with onLocationChanged event in Android. Here's the triggering: case R.id.start: { Points.add(overlay.getMyLocation()); // Points' type is ArrayList<GeoPoint> mgr.requestLocationUpdates(best, 0, 3, locationListener); } break; And here's the onLocationChanged method: public void onLocationChanged(Location location) { i++; Points.add(overlay.getMyLocation()); MapOverlay mapOverlay = new MapOverlay(Points.get(i-1), Points.get(i)); map.getOverlays().add(mapOverlay); //does the drawing mMapController.animateTo(Points.get(i)); } So, onLocationChanged is called only once and only

SWIFT - LocationManager looping through multiple times?

家住魔仙堡 提交于 2019-11-28 09:45:53
问题 I have a locationManager function to grab the users current location and posting the name of the city and state. I have a print statement so I can check in my console if everything is working properly...and it is. However, it prints the city location 3 times. This actually causes an issue in my actual app but thats beyond the point of this question. My function is as follows: var usersLocation: String! var locationManager: CLLocationManager! func locationManager(manager: CLLocationManager,

How to get initial location with LocationManager?

ぐ巨炮叔叔 提交于 2019-11-28 08:53:54
问题 I've been getting current location with GoogleApiClient up until now but I've just noticed that it's much simpler to do it with LocationManager using LocationListener since it can even detect when GPS service was turned on or off by the user. But I have a problem when getting user's first location after the LocationManager was initialized. LocationManager has 4 listeners but none of them give you your first location. It does have a onLocationChanged listener but it only activates when you

getLastKnownLocation return NULL using GPS_PROVIDER and NETWORK_PROVIDER

你说的曾经没有我的故事 提交于 2019-11-28 08:47:47
问题 This is my GPSTracker constructor class: public GPSTracker(Context context) { this.mContext = context; locationManager = (LocationManager) mContext.getSystemService(LOCATION_SERVICE); Location gpsLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); Location networkLocation = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); } gpsLocation and networkLocation are always NULL. getLastKnowLocation method doesn't return me any Location... even if I'm