android-location

Change Location Mode to High Accuracy Programmatically Android

♀尐吖头ヾ 提交于 2019-11-30 12:30:50
问题 Is it possible to get the information on the location mode which the user has selected among the three modes under the location settings options i.e 1.Hight Accuracy 2.Battery Saving 3.GPS Only I want to programmatically check if user has selected High Accuracy mode if not then enable it automatically. Is it possible ? Please advice. 回答1: It is possible to get the device's current location mode since API level 19 (Kitkat) : public int getLocationMode(Context context) { return Settings.Secure

Are there any advantages of using FusedLocationProviderApi over LocationManager?

时光怂恿深爱的人放手 提交于 2019-11-30 11:31:45
Earlier to get user current location I have used LocationManager: LocationManager locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE); if (locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) { location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); } else if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) { location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER); } It is easy to read and very straightforward code. But I have noticed that Google recently released New

distanceBetween() returns inaccurate result?

老子叫甜甜 提交于 2019-11-30 11:08:08
问题 I use distanceBetween() of Location class to calculate the distance between two points as follows: private float getDistanceInMiles(GeoPoint p1, GeoPoint p2) { double lat1 = ((double)p1.getLatitudeE6()) / 1e6; double lng1 = ((double)p1.getLongitudeE6()) / 1e6; double lat2 = ((double)p2.getLatitudeE6()) / 1e6; double lng2 = ((double)p2.getLongitudeE6()) / 1e6; float [] dist = new float[1]; Log.i("destination coordinates", "Latitude:" + lat2 + ", Longitude: " + lng2); Location.distanceBetween

Dramatic shift in location accuracy distribution starting February 15

断了今生、忘了曾经 提交于 2019-11-30 10:42:26
问题 I am trying to make sense of an inexplicable situation — starting February 15, a remarkably high percentage of the location readings we captured in our app are reporting exactly 10.0m accuracy, which seems strongly correlated with those arriving from a GPS source, as we see it almost exclusively with High-Accuracy and Sensor-Only mode (though there have been occasions where Battery Saving). After reviewing our system, we don't see any point where we could be introducing this ourselves. It

PRIORITY_LOW_POWER vs PRIORITY_BALANCED_POWER_ACCURACY for google play service v2

六眼飞鱼酱① 提交于 2019-11-30 07:07:36
I'm wondering for the fused location, does any of the above use a combination of gps + wifi network together? what is the difference in terms of provider (does any of it uses the gps)? from what i see in the documentation the difference is only distance I've previously worked with LocationManager and used NETWORK_PROVIDER and GPS_PROVIDER together to get a combination of those two provider. mike47 The new fused location providers take a slightly different approach compared to previous methods. Developers now choose how much battery power is used to calculate a location instead of which device

share location with share intent Activity

寵の児 提交于 2019-11-30 07:03:35
I need to share location from my app using the share intent activity, I have gone through some examples and know how to implement share intent. However I am stuck at setType. I need my application to share location details as well the users location on a map. By the way i copied a users code with a very similar question"no offence" Any assistance would be really appreciated. Intent intent1 = new Intent(Intent.ACTION_SEND); intent1.setType("text/plain"); intent1.putExtra(Intent.EXTRA_TEXT, "The status update text"); startActivity(Intent.createChooser(intent1, "Select prefered Service")); Ankit

How to get Location with Wifi in Android?

泄露秘密 提交于 2019-11-30 05:38:01
问题 I Want get location with Wifi and work in Google map, and it's not work for me but Gps is okay and not problem. my code: locationManager = (LocationManager) getSystemService(LOCATION_SERVICE); if (locationManager != null) { boolean gpsIsEnabled = locationManager .isProviderEnabled(LocationManager.GPS_PROVIDER); boolean networkIsEnabled = locationManager .isProviderEnabled(LocationManager.NETWORK_PROVIDER); if (gpsIsEnabled) { locationManager.requestLocationUpdates( LocationManager.GPS

Change Location Mode to High Accuracy Programmatically Android

此生再无相见时 提交于 2019-11-30 04:26:35
Is it possible to get the information on the location mode which the user has selected among the three modes under the location settings options i.e 1.Hight Accuracy 2.Battery Saving 3.GPS Only I want to programmatically check if user has selected High Accuracy mode if not then enable it automatically. Is it possible ? Please advice. kaolick It is possible to get the device's current location mode since API level 19 (Kitkat) : public int getLocationMode(Context context) { return Settings.Secure.getInt(activityUnderTest.getContentResolver(), Settings.Secure.LOCATION_MODE); } These are the

Calculating Speed for a navigation app without getSpeed() method

无人久伴 提交于 2019-11-30 04:25:23
I am developing an app which is more of a time-shift racing between your friends. I need to calculate speed of a moving vehicle, and I don't want to use Location.getSpeed() method. (Explained in detail in the bottom why I don't want to use it) I am trying to calculate speed with the help of Latitude and Longitude available to me, and this is where I need help. The help needed: I would want to know is: If the algorithm is correct Should I calculate in Centimeters instead of meters And if there's any code/library already available which does it. I am using the following code: This gives me

sending extra to requestLocationUpdates intentService breaks location updates

戏子无情 提交于 2019-11-30 03:58:24
I'm having trouble sending a string extra with my PendingIntent that I pass to LocationServices.FusedLocationApi.requestLocationUpdates(GoogleApiClient client, LocationRequest request, PendingIntent callbackIntent) . It appears that the username extra i'm putting onto the Intent is mangling the location that requestLocationUpdates is trying to hand off to my IntentService as intent.getParcelableExtra(FusedLocationProviderApi.KEY_LOCATION_CHANGED) returns null . EDIT I've tried making a User class that implements Parcelable and putting it as an extra: mRequestLocationUpdatesIntent.putExtra(