locationmanager

Problem requesting location updates by network

こ雲淡風輕ζ 提交于 2019-12-05 04:35:28
I've created a Service and grabs location data about the user so I can show my users nearby places. I want this Service to track by network in addition to GPS for 2 reasons: 1) GPS may not be enabled. 2) GPS takes quite a bit of time to lock on with my test phone. When my Service executes the following line: mNETEnabled = mLocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); I get the following error: 11-24 14:00:41.693: ERROR/LocationManagerService(51): isProviderEnabled got exception: 11-24 14:00:41.693: ERROR/LocationManagerService(51): java.lang.IllegalArgumentException:

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

不想你离开。 提交于 2019-12-05 03:25:52
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 = locationManager.getLastKnownLocation(LocationManager.PASSIVE_PROVIDER); System.out.println("1::"+loc)

Android Location not returning Location from Custom Class

一个人想着一个人 提交于 2019-12-04 21:51:58
I have my own location class. I have an odds result that when I search for the GPS location using my class, I get 0, 0 back. Whereas if I search the getLastKnown function in location manager for GPS, I get the forced value: public Location getGPSloc(Context c){ isGPSavailable(c); if(gps_enabled) lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 0, locationListenerGps); timerGPS = new Timer(); timerGPS.schedule(new GetLastLocationGPS(), 45000); return gpsLoc; } This is the class that I'm calling from outside the function, I am using this.getApplicationContext() in the call. This is

how do i send my location via url in sms?

我们两清 提交于 2019-12-04 21:08:14
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.sendTextMessage(ph, null, message, null, null); Toast.makeText(getApplicationContext(), "SMS SENT",

Android: Get current location in China

孤街醉人 提交于 2019-12-04 21:06:06
I need to get current location in China but current location manager is not working in china.Its not showing latitude and longitude. Please tell me how can I get this? Many Thanks Fact 1: All Google services are blocked in China. Fact 2: Although it gives a feeling that AOSP is nothing to do with Google, it's really not. The truth is that once you used NETWORK_PROVIDER to get a location, a message was send to Google location server to check out the location, and returned the location back to you. For the reason every Chinese knows about, you can't access the server, that's why when you combine

getting current location longitude and latitude in android

半世苍凉 提交于 2019-12-04 19:32:28
THis is my location class with this i am getting location longitude and latitude, but my problem is if i change my current location the longitude and latitude values are not updating. if i store my home location in my device, then my app is taking every time the same longitude and latitude values it is not taking my current location details. ex: I was in new york today and I launched a app and the location was my home in new jersey. public class GetLocation extends Activity { protected LocationManager locationManager; protected Button retrieveLocationButton; Context mContext; Double Longitude,

Android: GPS location updates when the cellphone is in sleep?

拜拜、爱过 提交于 2019-12-04 16:55:26
I need to update the location through GPS in the background even when the phone is in sleep. I am thinking to use AlarmManager to broadcast an Intent and then a receiver will call requestLocationUpdates() on LocationManager. But I am not sure whether it's guaranteed that the GPS location will be updated when the phone is in sleep and an intent will be broadcasted if I registered a PendingIntent when call requestLocationUpdates()? thanks, GPS aren't working when screen is off! You may set alarm for you app, but to get GPS position you must make screen on. Updated at 2016-08-23: Please be note,

Does anyone know whether the Android addProximityAlert on the LocationManager is battery intensive

*爱你&永不变心* 提交于 2019-12-04 14:10:09
问题 I just basically want to add about 20 and sometimes 80 Proximity Alerts with no time expiration with a radius of around 500 meters. Just wondering whether by doing this will suck up the battery real quick? also would it make any difference by reducing the radius? 回答1: This will definitely eat your battery real quick. You never want to be setting more than a couple of proximity alerts in any case, the use-case you describe isn't really catered for in Proximity Alerts. Proximity Alerts should

Android: how to find total distance covered using GPS when continuously moving?

泪湿孤枕 提交于 2019-12-04 14:06:50
This is my code. Please tell me y it is not able to calculate the distance.. In this code res is a long variable which is supposed to store the total distance covered. This code is supposed to calculate distance based on GPS as soon as there is a change in the latitude and longitude.. String serviceString = Context.LOCATION_SERVICE; LocationManager locationManager; locationManager= (LocationManager)getSystemService(serviceString); String provider = LocationManager.GPS_PROVIDER; final Location loc1=locationManager.getLastKnownLocation(provider); //Location loc1=new Location(""); String

Starting LocationManager as Service Android

空扰寡人 提交于 2019-12-04 13:19:00
问题 What I'm attempting to do is when receiving a c2dm message, start a service that asks for location for 'x' amount of time and then hands that location off to our server. The c2dm message starts the service correctly, and the GPS location turns on, but it never updates. It just sits there for the length of time I specify (currently 12 seconds) in the thread and does nothing. I'm using the exact same code somewhere else in my app (not as a service) and it works perfectly. What am I doing wrong?