locationmanager

Getting user location every n minutes after app goes to background

折月煮酒 提交于 2019-11-26 18:23:15
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. This is how I developed it: - (void)applicationDidEnterBackground:(UIApplication *)application { UIApplication* app = [UIApplication sharedApplication]; bgTask = [app beginBackgroundTaskWithExpirationHandler:^{ [app endBackgroundTask:bgTask]; bgTask = UIBackgroundTaskInvalid; }]; // Start the long-running task and return immediately. dispatch_async

LocationListener of NETWORK_PROVIDER is enabled but , onLocationChanged is never called

旧时模样 提交于 2019-11-26 17:22:59
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 why. It for some reason stop being called, but the Provider is enable and the Lister is working, when I Enable or disable the Provider manually, onProviderEnabled and onProviderDisabled is called. It just happens with NETWORK_PROVIDER , the GPS_PROVIDER works well. Listener: LocationListener locationListenerGPS = new LocationListener() { // @Override

Androids onStatusChanged not working

こ雲淡風輕ζ 提交于 2019-11-26 16:19:12
问题 I'm trying to get notifications if the status of GPS_PROVIDER changes. I found the following code here (http://hejp.co.uk/android/android-gps-example/), but I'm not getting notifications. Right now I'm in a building and can't get GPS signal, so wouldn't I get the notification "Status Changed: Out of Service"? When is onStatusChanged being called? What am I doing wrong? Thanks, @Override public void onStatusChanged(String provider, int status, Bundle extras) { /* This is called when the GPS

OnLocationChanged callback is never called

狂风中的少年 提交于 2019-11-26 13:00:00
问题 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 logcat. protected LocationListener locationListener; protected LocationManager locationManager; protected Context context; My OnCreate() method @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.v(TAG

NETWORK_PROVIDER not providing updated locations

守給你的承諾、 提交于 2019-11-26 12:38:18
问题 LocationManager locationManager = (LocationManager)getApp().getSystemService(Context.LOCATION_SERVICE); //getApp() returns my Application object locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER , 1, 1, this); locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 1, 1, this); That\'s the code I\'m using to listen. With GPS enabled, everything works fine. However, if I disable GPS and rely on network location, it gives me stale results -- in this case, from

Android check permission for LocationManager

假装没事ソ 提交于 2019-11-26 12:34:59
问题 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) findViewById(R.id.gps_coord_view); LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE); Location loc = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER); tv.setText(\"Latitude: \" + loc.getLatitude() + \"\\nLongitude: \" + loc.getLongitude());

LocationListener of NETWORK_PROVIDER is enabled but , onLocationChanged is never called

三世轮回 提交于 2019-11-26 05:24:42
问题 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 why. It for some reason stop being called, but the Provider is enable and the Lister is working, when I Enable or disable the Provider manually, onProviderEnabled and onProviderDisabled is called. It just happens with NETWORK_PROVIDER , the GPS_PROVIDER