locationmanager

Why isn't Android's onProviderEnabled() method being called?

家住魔仙堡 提交于 2019-11-28 07:28:19
问题 My Android app has two location listeners, one for fine and one for coarse listening. I want to be able to detect when the user turns their location services off and on. Whenever I turn my phones GPS or network location services OFF the onProviderDisabled method is called as expected. When I turn GPS or network services ON the onProviderEnabled is never called! I have put the code for one of the listeners below.... Update... I have discovered that the problem is related to unregistering the

GPS Android - get positioning only once

老子叫甜甜 提交于 2019-11-28 05:48:46
Is there a way to access the GPS once instead of having a looper that constantly checks for location updates? In my scenario all I'm interested in is finding the current co-ordinates and not a continuous connection with the GPS satellite. Does anyone have any ideas how this can be done? Thanks in advance. First check if the last know location is recent. If not, I believe you must to set up onLocationChanged listener, but once you get your first valid location you can always stop the stream of updates. Addition public class Example extends Activity implements LocationListener { LocationManager

Why does FusedLocationProviderApi never report accuracy better than 10m? Is this documented?

陌路散爱 提交于 2019-11-28 05:14:46
问题 A data collection app that used LocationManager directly was updated to use FusedLocationProviderApi . With LocationManager , most devices quickly report 5m accuracy or better when collecting location. With FusedLocationProviderApi , the best accuracy ever reported is 10m. I have just installed a location demo app and see the same behavior (https://github.com/will-quast/android-location-demo). In the Fused Location activity, if I only show GPS location, the accuracy changes as I get a better

LocationManager and jumping coordinates

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 02:21:45
问题 Take a look at this image. You see that some how LocationManager gives weird coordinates. It looks like they jump. But at the same time native google map app display correct location of the moving device. I tested app with 3 different smartphones under Android 7.0.0 and 7.1.1 and get the same result more or less. Please help me check my code to see which settings it is missing still. Thank you! import android.app.Service; import android.content.Context; import android.content.Intent; import

isProviderEnabled(LocationManager.NETWORK_PROVIDER) return false

二次信任 提交于 2019-11-28 01:49:47
I am using NETWORK_PROVIDER to get latitude and longitude of the place. I'v already check the setting in the "location & security" and enable "use wireless networks". But "isProviderEnabled(LocationManager.NETWORK_PROVIDER)" always return false . Can anyone help me? Thank you in advance! Here is my code : LocationManager locManager=(LocationManager) getSystemService(Context.LOCATION_SERVICE); boolean isEnableGPS=locManager.isProviderEnabled(LocationManager.GPS_PROVIDER); boolean isEnableNTW=locManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); Log.d(TAG, isEnableGPS+", "+isEnableNTW)

LocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER) is not reliable, why?

余生长醉 提交于 2019-11-28 00:06:19
One user of my app reported that app tells network for location is off even he did turn it on. He sent me few screen shots and they made me think; LocationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER) is not working properly. His phone is running Android 4.1.2 and first I thought this is the cause of this issue. But it was not the case. He sent me a screen shot of that setting too. Then I googled and found this . The question seems to help me but unfortunately answer was not helpful for this case and questioner did not pursue farther. My app is related to location and have been

Call requires permissions that may be rejected by user

旧城冷巷雨未停 提交于 2019-11-27 19:27:36
I am trying to make an application that sends location updates of a user after every five minutes. I suppose my code is working just fine but i get an error regarding the permissions that are being used by the application. I am pretty sure that i have added the permissions in the manifest file. Can someone tell me what's wrong? Here is my code. MainActivity.java LocationManager locationManager ; String provider; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Getting LocationManager object

Get current location during app launch

 ̄綄美尐妖づ 提交于 2019-11-27 16:29:48
问题 Good Day! I am working on an android app which monitors user location. I am using LocationManager to get users location, using the following method public void onLocationChanged(Location theLocation) {} Through the above method, whenever there was a user movement, I am receiving location coordinates. But, now I am planning to get user's location immediately after their app login. Is there any way through LocationManager through which I can manually get the location coordinates after my app

Androids onStatusChanged not working

╄→尐↘猪︶ㄣ 提交于 2019-11-27 13:23:19
I'm trying to get notifications if the status of GPS_PROVIDER changes. I found the following code here (http://hejp.co.uk/android/android-gps-example/), but I'm not getting notifications. Right now I'm in a building and can't get GPS signal, so wouldn't I get the notification "Status Changed: Out of Service"? When is onStatusChanged being called? What am I doing wrong? Thanks, @Override public void onStatusChanged(String provider, int status, Bundle extras) { /* This is called when the GPS status alters */ switch (status) { case LocationProvider.OUT_OF_SERVICE: Log.v(tag, "Status Changed: Out

Getting the current GPS location on Android

混江龙づ霸主 提交于 2019-11-27 12:36:08
问题 I'm trying to get the user's current location via GPS capability, Wrote a simple class that implements LocationListener public class LocationManagerHelper implements LocationListener { private static double latitude; private static double longitude; @Override public void onLocationChanged(Location loc) { latitude = loc.getLatitude(); longitude = loc.getLongitude(); } @Override public void onProviderDisabled(String provider) { } @Override public void onProviderEnabled(String provider) { }