android-location

Android: Check if Location Services Enabled using Fused Location Provider

[亡魂溺海] 提交于 2019-12-03 04:24:33
问题 According to the Android documentation: The Google Location Services API, part of Google Play Services, provides a more powerful, high-level framework that automatically handles location providers, user movement, and location accuracy than the platform location API in android.location . But using the fused location provider (from location APIs in Google Play services) I do not know how to check if the user has the location enabled or disabled. Using the old android.location it was easy:

Geofences not working when app is killed

不打扰是莪最后的温柔 提交于 2019-12-02 23:49:36
I know similar questions have been asked before but answers were not perfect. I created an app with geofences using the sample code from android developer website. I did not use any shared preferences to store geofences as I am not removing the geofences. I am testing the app from within the geofence, but my smartphone receives notifications every time the app runs and no notifications are observed when the app is killed. Why does this happen? I think I am supposed to receive notifications even when the app is killed. MainActivity public class MainActivity extends ActionBarActivity { @Override

When should I use ACCESS_COARSE_LOCATION permission?

£可爱£侵袭症+ 提交于 2019-12-02 21:01:35
I am building an Android app that will track the user's geolocation and draw their route on a map. I am using the Google Play Services location API, as described here . It is intuitive that my application requires the ACCESS_FINE_LOCATION permission, which I put in the manifest: <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> Do I also need the ACCESS_COARSE_LOCATION permission? What's the use case where I need the coarse location? Do I also need the ACCESS_COARSE_LOCATION permission? No. What's the use case where I need the coarse location? If you do not ask for

Android: Check if Location Services Enabled using Fused Location Provider

十年热恋 提交于 2019-12-02 17:37:30
According to the Android documentation: The Google Location Services API, part of Google Play Services, provides a more powerful, high-level framework that automatically handles location providers, user movement, and location accuracy than the platform location API in android.location . But using the fused location provider (from location APIs in Google Play services) I do not know how to check if the user has the location enabled or disabled. Using the old android.location it was easy: locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); locationManager.isProviderEnabled

Couldn't get user location

两盒软妹~` 提交于 2019-12-02 14:34:46
问题 I am trying to get user location either network location or gps location or both. for that i am running a background service which implements LocationListener . i added all the require permissions in the manifest file also. here is my service public class GetLocation extends Service implements LocationListener { LocationManager lm; Location networkLocation, gpsLocation; @Override public void onCreate() { super.onCreate(); lm = (LocationManager) getSystemService(LOCATION_SERVICE); if (lm

Android: How often does getLastKnownLocation(LocationManager.NETWORK_PROVIDER) return null in real life?

久未见 提交于 2019-12-02 11:06:21
问题 Do the Android users have the chance to reset the NetworkProvider, so that the location will be null? I came up with the idea, that its only possible to have that location null, after starting the device the very first time. But also than google will check the location right away for my opinion. Sure, I'm implementing a default location for this rare case. I just want to know how seldom this case is. 回答1: It returns 'null', when the Service is disabled in Settings > Location and Security >

Couldn't get user location

三世轮回 提交于 2019-12-02 08:22:38
I am trying to get user location either network location or gps location or both. for that i am running a background service which implements LocationListener . i added all the require permissions in the manifest file also. here is my service public class GetLocation extends Service implements LocationListener { LocationManager lm; Location networkLocation, gpsLocation; @Override public void onCreate() { super.onCreate(); lm = (LocationManager) getSystemService(LOCATION_SERVICE); if (lm.isProviderEnabled(LocationManager.GPS_PROVIDER)) { lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0

Wierd and very unexpected issue with location.getAccuracy()

谁都会走 提交于 2019-12-02 07:32:31
问题 Problem: I have tried using the new FusedLocationProviderClient and the deprecated FusedLocationApi to receive location updates on my app using a Sony Xperia Z2 and Huawei Honor 8 . Everything works fine initialy. However it seems that after x amount of location requests the accuracy number NEVER drops below 10.0 using location.getAccuracy(); // 10.0 What I have tried: Uninstalling and reinstalling the app does no difference. Restarting the phone, same result. Yes I have LocationRequest

Android requestLocationUpdates with GPS null

只愿长相守 提交于 2019-12-02 07:10:59
问题 private void getLocation(){ locationManager = (LocationManager) getContext().getSystemService(Context.LOCATION_SERVICE); List<String> providers = locationManager.getAllProviders(); for (String provider : providers) { Log.e("GPS_provider: ", provider); } Criteria criteria = new Criteria(); bestProvider = locationManager.getBestProvider(criteria, false); Log.e("Best_provider: ", bestProvider); locationListener = new LocationListener() { public void onLocationChanged(Location location) { //

How to get location when it changes

别说谁变了你拦得住时间么 提交于 2019-12-02 07:03:26
I would like to know there is a way to get location if only it changes? I know android provides this http://developer.android.com/training/location/receive-location-updates.html to get location updates and as it states: "If your app does navigation or tracking, you probably want to get the user's location at regular intervals. While you can do this with LocationClient.getLastLocation(), a more direct approach is to request periodic updates from Location Services. In response, Location Services automatically updates your app with the best available location, based on the currently-available