locationlistener

How can I send a notification from inside the onProviderDisabled method of a LocationListener

末鹿安然 提交于 2020-01-16 14:08:13
问题 How can I send a notification from inside the onProviderDisabled method of a LocationListener? So far I have been using: Toast.makeText(mainmenu, "GPS Location providers are disabled... blah blah", Toast.LENGTH_LONG).show();}}); but that entails using a static mainmenu variable stored when the mainmenu class is first instantiated - I gather doing it that is a bad idea, in case the mainmenu object gets removed from memory I guess - so I think I should be using notifications. I guess I need to

Android requestLocationUpdates minimumtime + minimumdistance don't really work

强颜欢笑 提交于 2020-01-15 10:46:05
问题 locationmanager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, locationlistener); I understand that this line of code is supposed to update the device location as frequently as possible right? Specifically, every 0miliseconds and 0metres (minimum). Okay, the word ' minimum ' is key here but still, why sometimes the location is not updated for maybe as long as 30+ seconds? I have timed the actual time between one update and the next, while on WiFi, and it took 38 seconds even

How to get current location in android 7?

浪尽此生 提交于 2020-01-11 11:30:13
问题 I'm trying to get current location in android and its OK when i'm using on android M or lower, But when i run my application on android N, location is null and when i want get latitude from it will returns 0. here is my code try { if (!isGPSEnabled && !isNetworkEnabled) { } else { this.canGetLocation = true; if (isNetworkEnabled) { locationManager.requestLocationUpdates( LocationManager.NETWORK_PROVIDER, MIN_TIME_BW_UPDATES, MIN_DISTANCE_CHANGE_FOR_UPDATES, this); Log.d("Network", "Network");

Trying to get current location through onConnected() method

和自甴很熟 提交于 2020-01-05 09:34:19
问题 I'm trying to get my current location through the onConnected() method. But unfortunately onMapReady() gets called earlier. Because of that my variables currentLatitude and currentLongitude contains the value 0.0 as you can see in the logs below: I/System.out: currentLatitude : 0.0 I/System.out: currentLongitude : 0.0 D/: HostConnection::get() New Host Connection established 0xeec39820, tid 23599 I/System.out: onConnected I had already tried to use AsyncTask but that doesn't work because

Trying to get current location through onConnected() method

六眼飞鱼酱① 提交于 2020-01-05 09:34:05
问题 I'm trying to get my current location through the onConnected() method. But unfortunately onMapReady() gets called earlier. Because of that my variables currentLatitude and currentLongitude contains the value 0.0 as you can see in the logs below: I/System.out: currentLatitude : 0.0 I/System.out: currentLongitude : 0.0 D/: HostConnection::get() New Host Connection established 0xeec39820, tid 23599 I/System.out: onConnected I had already tried to use AsyncTask but that doesn't work because

LocationManager.removeUpdates(listener) not removing location listener

限于喜欢 提交于 2020-01-03 12:58:18
问题 My app scenario is that I want to track employees location. I have a broadcastreceiver which listens device boot broadcast and register an alarm manager. When alarm manager ticks, it registers two location listeners, one to listen to gps and other for network. I want that when I got first location update in onLocationChange() method, save location and unregister that location listener so that when alarm manager ticks again, it does not get duplicate. To unregister, I have location listeners

LocationManager.removeUpdates(listener) not removing location listener

删除回忆录丶 提交于 2020-01-03 12:58:00
问题 My app scenario is that I want to track employees location. I have a broadcastreceiver which listens device boot broadcast and register an alarm manager. When alarm manager ticks, it registers two location listeners, one to listen to gps and other for network. I want that when I got first location update in onLocationChange() method, save location and unregister that location listener so that when alarm manager ticks again, it does not get duplicate. To unregister, I have location listeners

Android LocationListener leave on while phone asleep

谁说我不能喝 提交于 2020-01-03 03:28:08
问题 I set an alarm with the flag RTC_WAKEUP to run a IntentService every 30 seconds to transmit location updates to a server. I'm planning to change the flag to RTC so it won't wake up the phone and just run when another process wake ups the phone. If I leave a LocationListener registered, will it still listen for location updates while the phone is asleep? 回答1: Yes - working location service has it's own wake lock. However better approach is manually set proper wake lock in your broadcast

Android onLocationChanged and MainActivity class

非 Y 不嫁゛ 提交于 2019-12-24 14:01:14
问题 I have the following code: public class MyLocationListener implements LocationListener { @Override public void onLocationChanged(Location loc) { // called when the listener is notified with a location update from the GPS Log.d("Latitude", Double.toString(loc.getLatitude())); Log.d("Longitude", Double.toString(loc.getLongitude())); } @Override public void onProviderDisabled(String provider) { // called when the GPS provider is turned off (user turning off the GPS on the phone) } @Override

Getting longitude and latitude takes a very long time

梦想与她 提交于 2019-12-24 12:07:36
问题 I am getting the longitude and latitude of my device, but it takes at 30 seconds to a minute to do so. Any suggestions to cut the time down? public class MainActivity extends Activity { public String zipcode; public double latG; public double lonG; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); LocationManager service = (LocationManager) getSystemService(LOCATION_SERVICE); boolean enabled = service