locationmanager

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

眉间皱痕 提交于 2019-12-22 03:59:08
问题 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) this.getSystemService(Context.LOCATION_SERVICE); if (locationManager != null) { Location lastKnownLocationGPS = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); if (lastKnownLocationGPS != null) { return lastKnownLocationGPS; } else { Location loc

how do i send my location via url in sms?

此生再无相见时 提交于 2019-12-22 01:19:48
问题 i am making a android project so can anyone tell me how do i send my current location in URL via SMS . Let me explain what i want to know when the mobile got a shake then my app sent a string SMS to selected contact now i want to add location feature in my app mean i want to send the location via URL in SMS ,when the receiver hit on URL then he can the location of sender in his map ? private void sendSMS(String ph, String message) { SmsManager smsManager = SmsManager.getDefault(); smsManager

Android : Difference between LocationManager.addProximityAlert() & LocationClient.addGeofences()

隐身守侯 提交于 2019-12-21 20:37:33
问题 Both of these serve as a mechanism to notify once the user enters/exits a given point of interest. What are the pros and cons of each ? 回答1: Coming from someone who switched over to Google Play Services a while ago, i can give you some experiences: I have an app, about 2,5 years old, that uses location services extensively. From the outset, of course, we used the LocationManager since that's what was available on the Android platform. We had a pretty bad experience with Location Services on

Android: Send location data in background periodically (every 30 seconds) and ask server for new data

你说的曾经没有我的故事 提交于 2019-12-21 17:32:00
问题 Scenario: Post to server to get any new data in background every 30 seconds for long period i.e. 12 hours. Location data needs to be sent along with this. Current Implementation; Service Class; Location listener with interval of 30 seconds which sets the longitude & latitude values to two local variables Alarm manager fires pending Intent every 30 seconds to a broadcast receiver. Broadcast receiver starts an IntentService with location variables in the extras. The IntentService http posts

GPS icon is still blinking after locationManager.removeUpdates() and by setting locationManager to null

浪尽此生 提交于 2019-12-21 11:28:09
问题 I am developing the Location Tracking application. But i am stopping getting the location update by doing 2 things... locationManager.removeUpdates(this); and setting locationManager reference to null. This will stop getting location co-ordinates as i want... But the problem is the gps icon is still blinking.. which will draining the device's battery. So please help me in stopping this GPS fixes... 回答1: If you display your position and/or the compass in your mapView, you have to disable them.

RequestLocationUpdates parameter android

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 05:34:18
问题 I have confusion in this parameter locationManager.requestLocationUpdates(provider, 60000, 10, listener); So here is how it executes location update listener . if time = 60000 AND distance = 10 then it will execute or if time = 60000 OR distance = 10 then it will execute. Please help me to come out this confusion. 回答1: According to the docs : The elapsed time between location updates will never be less than minTime So minTime takes precedence. Further on it says : The minDistance parameter

What is the meaning of android.location.LocationManager.PASSIVE_PROVIDER?

回眸只為那壹抹淺笑 提交于 2019-12-21 04:13:20
问题 I understand the meaning of GPS_PROVIDER (locations come from GPS signals) and NETWORK_PROVIDER (locations are determined from cell towers and wireless access points), but I don't understand the meaning of PASSIVE_PROVIDER, despite the definition in the API: A special location provider for receiving locations without actually initiating a location fix. This provider can be used to passively receive location updates when other applications or services request them without actually requesting

How to stop location manager?

为君一笑 提交于 2019-12-21 03:09:14
问题 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 { lmanager = (LocationManager)getSystemService(Context.LOCATION_SERVICE); lmanager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0, this); lmanager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, this); } catch(Exception e) { e.printStackTrace(); } }

How does getSystemService() work exactly?

亡梦爱人 提交于 2019-12-20 08:19:39
问题 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. However the object returned by the getSystemService seems to be singleton which lives outside the scope of MainActivity (appropriately so since it is a system service :) ) After taking a heap dump and going through it with the Eclipse Memory

Location manager doesnt remove location updates! [duplicate]

那年仲夏 提交于 2019-12-19 10:32:28
问题 This question already has an answer here : Closed 7 years ago . Possible Duplicate: Android: how to cancel a request of Location update with intent? I am trying to disable a pending intent(broadcast) which I have previously created in a different activity but I can't get it to work. I've read that I should recreate the intent(with the same extras and everything), pass it as a parameter so that I can instantiate the pendingIntent and then pass the pendingIntent as a parameter to the location