locationmanager

Location returns NULL

拟墨画扇 提交于 2019-12-02 07:08:03
问题 I am writing an Android app that returns longitude and latitude, however location holds a Null value. Please see if you can see why, Its been bugging me all day. Code below: public class example extends Activity { public static double latitude; public static double longitude; LocationManager lm; LocationListener ll; Location location; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView

Location returns NULL

跟風遠走 提交于 2019-12-02 03:00:42
I am writing an Android app that returns longitude and latitude, however location holds a Null value. Please see if you can see why, Its been bugging me all day. Code below: public class example extends Activity { public static double latitude; public static double longitude; LocationManager lm; LocationListener ll; Location location; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.questions); lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); ll = new

Significant blocation change event in ios7 - Background service call

冷暖自知 提交于 2019-12-02 01:58:22
问题 I am using Significant location services in my app. If my app killed by system or force close by user, using event of Significant location change services I am sending location data to my server,in iOS 6. In iOS6 my app sends data to server after force close also. But in iOS 7 I am not getting this significant location change event. 回答1: As iOS 7 SDK is not under NDA anymore, I'm posting the answer here, for the sake of completion. As mentioned in answers here: Monitoring regions but location

Significant blocation change event in ios7 - Background service call

喜欢而已 提交于 2019-12-02 00:34:22
I am using Significant location services in my app. If my app killed by system or force close by user, using event of Significant location change services I am sending location data to my server,in iOS 6. In iOS6 my app sends data to server after force close also. But in iOS 7 I am not getting this significant location change event. Legoless As iOS 7 SDK is not under NDA anymore, I'm posting the answer here, for the sake of completion. As mentioned in answers here: Monitoring regions but location icon disappears when app is killed iOS 7 does not allow significant location changes in background

Programmatically turn ON GPS in android [duplicate]

落爺英雄遲暮 提交于 2019-12-01 13:19:42
问题 This question already has answers here : Android 4.1.2 How to turn off GPS programmatically (5 answers) Closed 5 years ago . Possible duplicates, How to enable/disable gps and mobile data in android programmatically? I have been seeing people telling that they are able to turn ON the GPS in android programatically. But I'm using the same code and not able to do that. It is just showing that "Searching for GPS .." but not actually doing it. Here is the code I'm using, //Enable GPS Intent

Why is locationmanager returning old location fixes with new gettime-timestamp?

社会主义新天地 提交于 2019-12-01 05:21:42
We have an app that upon user action tries to get a location fix. It listens both on GPS and network and has a time/accuracy based decision matrix to determine when to stop listening and what fix to return. We have noticed, on occasion, a very strange behaviour. We use the classic way to see how old the fix is, like so: long age = now - newLocation.getTime(); if(age >= prefs.getLocationMaxAge()){ Log.d(TAG, "location too old."); return; } But sometimes, the location.getTime returned from the OS has an age of perhaps 15-20 seconds, according to the returned timestamp, although we can tell for

Get location (coordinates) periodically without dramatically increase battery consumption

江枫思渺然 提交于 2019-12-01 04:43:45
I'm developing an Android application; this App needs to send periodically (every 10 minutes) the current position (coordenates) to a web service. But ... I'm a little confused about the more correct way (and friendlier to the device battery) to do that. I read this answer and her method _getLocation() looks well; but I don't know whether that method could get the availability of the location I need; total availability... I would like, if the location is not available using GSM / WIFI, application choose the GPS method. Is that what makes this method? private void _getLocation() { // Get the

Get location (coordinates) periodically without dramatically increase battery consumption

牧云@^-^@ 提交于 2019-12-01 02:29:58
问题 I'm developing an Android application; this App needs to send periodically (every 10 minutes) the current position (coordenates) to a web service. But ... I'm a little confused about the more correct way (and friendlier to the device battery) to do that. I read this answer and her method _getLocation() looks well; but I don't know whether that method could get the availability of the location I need; total availability... I would like, if the location is not available using GSM / WIFI,

onLocationChanged() never called

百般思念 提交于 2019-11-30 17:23:38
I am writing a code that brings current location but it is not giving me the location because it never calls onLocationChanged() .Is there any way to find the location. mobileLocation is coming 0 for this case, so the execution goes to the else block. My code is public class FindLocation { private LocationManager locManager; private LocationListener locListener; private Location mobileLocation; private String provider; public FindLocation(Context ctx){ locManager = (LocationManager) ctx.getSystemService(Context.LOCATION_SERVICE); locListener = new LocationListener() { @Override public void

How to get the current location of iPhone through code?

。_饼干妹妹 提交于 2019-11-30 13:31:59
问题 How do you get the current location of iPhone through code? I need to track the location using GPS. 回答1: You're looking for the "CoreLocation" API. Here's a tutorial 回答2: There is (as always for core functionality) comprehensive documentation on the developer site and you may find this example useful; The key points to remember are; 1) Once you start receiving location updates, they arrive asynchronously and you need to respond to them as and when they come in. Check the accuracy and