android-location

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

Animating car Marker movement on map V2

房东的猫 提交于 2019-12-11 10:18:02
问题 I am animating car moving on a street with real time location updates. But the car is facing to true north and the bearing returns 0.0 no matter which direction I am moving. Is there any hack to make the front of my car moving the direction I am moving. Here is my code. private void draw_current_location(Location currentlocation) { LatLng current = new LatLng(currentlocation.getLatitude(), currentlocation.getLongitude()); CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngZoom(current,

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{

NullPointerException - Location - getLatitude() method [duplicate]

隐身守侯 提交于 2019-12-11 07:12:10
问题 This question already has an answer here : Android getlastknownlocation returns null (1 answer) Closed 6 years ago . I'm receiving a null pointer exception on this line: double latitude = location.getLatitude(); Is there anything I need to be doing to initialize my Location variable? What am I doing wrong? Here is my source code: Location location; if (isGpsEnabled) { location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); } else { location = locationManager

Crash onLocationChanged() Android

老子叫甜甜 提交于 2019-12-11 05:16:47
问题 I am getting a crash in onLocationChanged() method and this is what I get in logCat 04-10 00:51:43.354: E/AndroidRuntime(4132): FATAL EXCEPTION: main 04-10 00:51:43.354: E/AndroidRuntime(4132): Process: com.dd.assistant, PID: 4132 04-10 00:51:43.354: E/AndroidRuntime(4132): java.lang.NullPointerException 04-10 00:51:43.354: E/AndroidRuntime(4132): at com.twixkat.assistant.MainActivity.onLocationChanged(MainActivity.java:1314) 04-10 00:51:43.354: E/AndroidRuntime(4132): at android.location

Calculation for latitude and longitude from start to destination point

混江龙づ霸主 提交于 2019-12-11 04:13:07
问题 Hi I am new to android development. I am on college project its based on location which is need to find list of latitude and longitude in between two points. Given Starting position is 12.990143,80.215784 and destination position is 12.992595,80.217618. Over the past days i search the google, i found so many links to find distance between locations and mid point. I cant able to find solution for my problem. Please suggest some solution for this problem. I am struggling over days to find

Android- Google Maps V2 : Trace route from current position to an other destination

梦想的初衷 提交于 2019-12-11 03:37:25
问题 I started with this example, to draw a route between 2 address, type by the user. It is working. http://blog.rolandl.fr/1357-android-des-itineraires-dans-vos-applications-grace-a-lapi-google-direction But now I would like to draw a route from my current position to an other destination, type by the user. My problem is that I don't know how to retrieve the current position, in this case. I've tried to do : LocationManager locationmanager=(LocationManager)this.getSystemService(LOCATION_SERVICE)

Location Permissions on Android 5.1

孤街醉人 提交于 2019-12-10 20:44:58
问题 We have built and deployed a location-based shopping app that worked perfectly. That is until we discovered that our app does not work on Android 5.1.1 devices due to a Security Exception thrown. After a little research I discovered that Google has created a new method of asking for permissions at runtime but did not see any clear ways of doing that. Can anyone give clear guidelines/lines of code of requesting permission from the user at runtime. Will the app also have to do this every time

Unable to get GPS Location with Common Code

拈花ヽ惹草 提交于 2019-12-10 19:16:05
问题 I have code to get location, which I believe must be working but it doesn't at all: Manifest : <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> Java : LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);

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