android-location

Best Practice to report user location continuously

岁酱吖の 提交于 2020-01-20 15:16:22
问题 I'm designing an application where application in server side need to be continuously aware of user location. I'm thinking to create an Android service that run in the background and continuously query user location and send the result to an application in the backend server. However, I wonder if this is the best approach in terms of battery saving. For example, in iOS, there is something called "Significant-Change" to serve such purpose, does Android have similar thing. 回答1: I suggest to

Best Practice to report user location continuously

霸气de小男生 提交于 2020-01-20 15:16:06
问题 I'm designing an application where application in server side need to be continuously aware of user location. I'm thinking to create an Android service that run in the background and continuously query user location and send the result to an application in the backend server. However, I wonder if this is the best approach in terms of battery saving. For example, in iOS, there is something called "Significant-Change" to serve such purpose, does Android have similar thing. 回答1: I suggest to

LocationManager's getBestProvider returning null

最后都变了- 提交于 2020-01-19 05:38:47
问题 I have a bunch of people reporting an error that I cannot reproduce. When trying to open a MapView it's reporting that the getBestProvider is returning null and I know that means that that no provider is found that fulfills my criteria which is ACCURACY_COARSE so if there is no GPS then it should fall back on either network or passive but it obviously doesn't on those user devices. What would that even mean then that GPS is off and there is no network connection? I tried turning GPS off and

How does the distanceTo() method of the Location class work internally?

本秂侑毒 提交于 2020-01-17 14:07:23
问题 I've tried using distanceTo() between two Location objects, but AFAIK it isn't returning the correct values in all situations. Instead, I've written a custom method which returns what I think are the correct values. float distanceBetween(Location l1, Location l2) { float lat1= (float)l1.getLatitude(); float lon1=(float)l1.getLongitude(); float lat2=(float)l2.getLatitude(); float lon2=(float)l2.getLongitude(); float R = 6371; // km float dLat = (float)((lat2-lat1)*Math.PI/180); float dLon =

Android LocationClient.getLastLocation() returns old and inaccurate location with a new timestamp

隐身守侯 提交于 2020-01-11 06:08:20
问题 I've been using the fused location provider since its release and I am pretty happy with it (way better than the old system). But I ran into a peculiar problem when using geofencing in combination with LocationClient.lastKnownLocation(). The setup is as follows: I drop several geofences around some home location (with increasing ranges). When I get the intent that a fence is crossed I retrieve the last known location from LocationClient and work with it. Apart from than I also registered for

Android LocationClient.getLastLocation() returns old and inaccurate location with a new timestamp

倖福魔咒の 提交于 2020-01-11 06:05:30
问题 I've been using the fused location provider since its release and I am pretty happy with it (way better than the old system). But I ran into a peculiar problem when using geofencing in combination with LocationClient.lastKnownLocation(). The setup is as follows: I drop several geofences around some home location (with increasing ranges). When I get the intent that a fence is crossed I retrieve the last known location from LocationClient and work with it. Apart from than I also registered for

Location Client request location updates with parcelable extras in PendingIntent

别等时光非礼了梦想. 提交于 2020-01-10 04:14:29
问题 I am using LocationClient with PendingIntent to get location updates. PendingIntent.getService(context, 0, new Intent(context, OnLocationAvail.class), PendingIntent.FLAG_UPDATE_CURRENT) The Above code works fine I get the location from the key LocationClient.KEY_LOCATION_CHANGED But when I have an extras of parcelable data as described below, the service gets called with the parcelable data but the key LocationClient.KEY_LOCATION_CHANGED in the intent extras is always null. Intent

Location Client request location updates with parcelable extras in PendingIntent

狂风中的少年 提交于 2020-01-10 04:14:07
问题 I am using LocationClient with PendingIntent to get location updates. PendingIntent.getService(context, 0, new Intent(context, OnLocationAvail.class), PendingIntent.FLAG_UPDATE_CURRENT) The Above code works fine I get the location from the key LocationClient.KEY_LOCATION_CHANGED But when I have an extras of parcelable data as described below, the service gets called with the parcelable data but the key LocationClient.KEY_LOCATION_CHANGED in the intent extras is always null. Intent

Android: Service to get and send GPS co-ordinates to server

こ雲淡風輕ζ 提交于 2020-01-06 10:51:16
问题 I know this is duplicate question, but I am not getting the explanatory example or solution. I want to develop an application which after run calls a background service which takes the GPS location of device and send it via PHP web service to the server. And when user wants, he can stop the service. I am working on service for the first time. I searched on google and found many tutorial, but not getting it. So please guide me for this. 回答1: you can able to send current location or lat and lag

Getting current location from GPS

ぃ、小莉子 提交于 2020-01-06 02:58:09
问题 Using Criteria.ACCURACY_COARSE I get the location but it is not accurate. I wanted to use GPS Criteria.ACCURACY_FINE but the onLocationChanged(Location location) method is not called. I did some researches but could not figured why. There are lots of similar questions on StackOverflow but unfortunately I could not find one that clear my issue. Below is my source code: private void locationInformationSettings(){ Criteria criteria= new Criteria();; criteria.setAccuracy(Criteria.ACCURACY_FINE);