locationmanager

Service is stopped after a few minuets of inactivity

蹲街弑〆低调 提交于 2019-12-11 18:03:24
问题 I am writing an android app using the GPS location provider in a Service that is started when the main Activity is created (unless the service is already running). I was under the impression that the service would continue to run with the unlikely exception that the task manager could killed it if there was a memory shortage. For some reason the service is restarted if there is a period of very low activity regardless of how much memory is available. When the user is outside and the GPS is

Location Method Calls Crashes On Some Devices

旧巷老猫 提交于 2019-12-11 13:16:09
问题 I've got an app that uses MapView and I print out the user's latitude, longitude and horizontal accuracy to some labels. This all works fine on my HTC Wildfire, but on my SE Xperia the app crashes whenever I try to touch Location.getLatitude() , Location.getLongitude() or Location.getAccuracy() . I've got a hunch that it could be the GPS on the Xperia being so slow the location manager hasn't obtained its coordinates when I'm polling for lat, long and accuracy - but how can i safeguard

How to better handle GPS location and android

时光毁灭记忆、已成空白 提交于 2019-12-11 12:09:01
问题 I have a fragment with a listview in it, that retrieves the users location, then updates the list view based on the users location. The problem with my code, is that it seems to grab the location update the list, then keep updating. And reloading the list, almost to the point of annoyance. Here is my code: public class FindBrewery extends Fragment implements LocationListener { private TextView latituteField; private TextView longitudeField; LocationManager locationManager; private String

Location Provider SAMSUNG always returns true

天大地大妈咪最大 提交于 2019-12-11 08:27:34
问题 I am trying to check if it is possible to fetch the location using Location Manager using the below procedure LocationManager service = (LocationManager).getSystemService(Context.LOCATION_SERVICE); boolean network = service.isProviderEnabled(LocationManager.NETWORK_PROVIDER); The above logic works fine in Sony Ericsson, but when it comes to samsung, 'service.isProviderEnabled(LocationManager.NETWORK_PROVIDER)' always returns true., even with GPS , WiFi turned OFF and even with out a SIM card

LocationManager still cant find last known location after GPS is turned on

送分小仙女□ 提交于 2019-12-11 07:34:50
问题 I'm having a problem with android where even after the user turns their location service on, the LocationManager still can't find the users location. Before I launch the activity that needs to use the user's location I call the following: //Menu Activity LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE); if(lm.isProviderEnabled(LocationManager.GPS_PROVIDER){ Intent nearby = new Intent(mActivityContext, NearbyActivity.class); startActivity(nearby); }else{

Android location always null

心不动则不痛 提交于 2019-12-11 04:53:45
问题 I had my application to find location working, but I changed some code and now the location always returns null. Ashamedly I am not sure what code I had changed, but I just cant seem to get it working. Can anyone see why this returns null? I have been working on this all day with no joy. code below: ....imports.... public class Clue extends Activity { public static double latitude; public static double longitude; Criteria criteria; LocationManager lm; LocationListener ll; Location location;

Clarification on min distance on LocationManager.requestLocationUpdates method, min Distance parameter

倖福魔咒の 提交于 2019-12-11 03:16:03
问题 I researched online and saw that Location Manager.requestLocationUpdates method and saw that it took an argument of minDistance. The definition that the site(http://blog.doityourselfandroid.com/2010/12/25/understanding-locationlistener-android/) gave me for that argument was "minimum distance interval for notifications" with an example of 10 meters. Can anyone clarify what that means? Everytime i move 10 meters with a phone, i get an gps update? 回答1: Yes, essentially this means that if the

Set parameters of android.location.Location object from JUnit unit test

好久不见. 提交于 2019-12-10 19:03:45
问题 I'm trying to make unit test for a function which receive android.location.Location object. But i blocked because i don't have possibility to set up parameters for Location object. @Test public void testLocation() { Location location = new Location("gps"); location.setAccuracy(25F); location.setTime(5123L); System.out.println("Accuracy: " + location.getAccuracy()); System.out.println("Time: " + location.getTime()); } Output: Accuracy: 0.0 Time: 0 Process finished with exit code 0 Location

[Android-Location]Can not get Longitude and Latitude from LocationManager

柔情痞子 提交于 2019-12-10 12:02:16
问题 I used LocationManager to get user address by "Longitude" and "Latitude" but when i call location.getLongitude() and location.getLatitude(), it return 0 back to me. I manage to Google but have nobody meet my issue. Mr.Jeremy Edwards suggest me that: Make sure that network based location is enabled in the phone's settings. You can detect this situation and prompt the user to enable it if you really need it. I believe this is the line of code to launch this activity. I do that but it can help.

Android: Get current location in China

守給你的承諾、 提交于 2019-12-10 00:40:39
问题 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 回答1: 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