android-location

Error adding geofences in Android (status code 1000)

雨燕双飞 提交于 2019-11-27 14:17:46
I am getting an error in the onAddGeofencesResult(int statusCode, String[] geofenceRequestIds) callback with statusCode = 1000 . I have my GPS enabled and my WiFi. I also have Google Play Services and I am able to track my location and request updates. Why am I not able to add geofences? I am not able to add geofences even from the documentation sample app. I get the following Toast message: "Add Geofences: Failure, error code 1000 GeofenceRequestIds=[1,2,1,2]" From the documentation (statusCode 1000): public static final int GEOFENCE_NOT_AVAILABLE Geofence service is not available now.

Comparing two locations using their Longitude and Latitude

风流意气都作罢 提交于 2019-11-27 11:58:45
Hi i need to cal an event at onchangelocation(), by comparing current latitude and longitude with some saved latitude and longitude but i m getting an error. eclipse is not recognizing key word distance, and for correction error it is giving hint to crate method "distance" having 4 parameter ... how to fix it??? or some other way to do same work??? thanks and regards. code is attached below @Override public void onLocationChanged(Location location) { double currentLat=location.getLatitude(); double currentLon=location.getLongitude(); if (distance(lat,lon,currentLat,currentLon)<2.0){ //do what

Why is FusedLocationApi.getLastLocation null

纵饮孤独 提交于 2019-11-27 07:34:33
I am trying to get location by using FusedLocationApi.getLastLocation and I've got the location permissions in the manifest file: <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> However, I am getting null when I request the location from the system. I was just testing turning off and on location services so it may be related to that (of course, it's ON when I'm trying this). But even after returning null, I'm waiting for onLocationChanged to be called and it's never called. I've also seen a

How to write Espresso Tests which are mocking GPS locations and use them in Google Testlab?

笑着哭i 提交于 2019-11-27 04:51:03
问题 I recorded an espresso test with Espresso Recorder. I want to test some location changes in my app. Currently I'm mocking the location with this code: LocationManager lm = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); criteria.setAccuracy( Criteria.ACCURACY_FINE ); String mocLocationProvider = LocationManager.GPS_PROVIDER;//lm.getBestProvider( criteria, true ); lm.addTestProvider(mocLocationProvider, false, false, false, false, true,

ACCESS_COARSE_LOCATION permission gives a cell tower precision on Android

那年仲夏 提交于 2019-11-27 04:05:29
I am making some tests with the requestLocationUpdates() function from the FusedLocationApi . I am using the PRIORITY_BALANCED_POWER_ACCURACY . A city block precision is fine for me. When I request the ACCESS_FINE_LOCATION permission, I get around a 100m precision which is great with GPS off. As I do not need a GPS precision but a city block precision, I would like to request only the ACCESS_COARSE_LOCATION permission. However when I request the ACCESS_COARSE_LOCATION permission, I get a 2 km precision. It seems that the device does not use anymore the Wifi permission and only a cell tower

Stop Location Listener in Android

余生颓废 提交于 2019-11-27 03:04:55
问题 In my android app I need to get current GPS location of the user at the start of the application only if location has change from the previous location. But the problem is when I inside the application if location change ( ie If user was traveling while using the app) app is starting from the beginning. I need to stop location listener after getting user current location. removeUpdates method didn't work for me. Please help me on this issue. thanks in advance ! 回答1: mLocManager.removeUpdates

Finding current location of the user in Android

耗尽温柔 提交于 2019-11-27 02:24:33
I am new to Android and I am trying to develop an Android app which shows current location of the user. I am using Genymotion. Now I am using mLocation=LocationServices.FusedLocationApi.getLastLocation(mGoogleClient); to get the last location of the device. The thing is I wanted to get the current location but with this I get mlocation as not null that's fine. But in the map it shows last location of the device always not the current location. code snippet @Override public void onConnected(Bundle bundle) { Log.i(TAG, "inside onconnected Location services connected"); Location mLocation=null;

Android - How to get estimated drive time from one place to another?

烈酒焚心 提交于 2019-11-27 00:24:18
问题 I need to find the estimate drive time from one place to another. I've got latitudes and longitudes for both places but I have no idea how to do that. Is there is any API for that. help thanks. 回答1: yes you get the time and distance value as well as many like direction details in driving, walking etc mode. all you got from the google direction api service check our this links http://code.google.com/apis/maps/documentation/directions/ 回答2: Location location1 = new Location(""); location1

Determining the speed of a vehicle using GPS in android

≯℡__Kan透↙ 提交于 2019-11-26 23:53:17
问题 I would like to know how to get the speed of a vehicle using your phone while seated in the vehicle using gps. I have read that the accelerometer is not very accurate. Another thing is; will GPS be accessible while seated in a vehicle. Won't it have the same effect as while you are in a building? Here is some code I have tried but I have used the NETWORK PROVIDER instead.I will appreciate the help. Thanks... package com.example.speedtest; import android.app.Activity; import android.content

getLastKnownLocation() returns null [closed]

好久不见. 提交于 2019-11-26 23:17:05
I have read a lot of Q&As on this topic here on SO but I have to say that none of them works. My problem is that, even though I have GPS enabled, I cannot get a location unless I open Google Maps and get my location and then go back to the app, which is definitely not an option for the users. I have the following function to get the location. public Location getCurrentLocation() { LocationManager locationManager = (LocationManager) context .getSystemService(Context.LOCATION_SERVICE); Criteria criteria = new Criteria(); String provider = locationManager.getBestProvider(criteria, true); Location