My android app relies on location. However the FusedLocationProvider which I use for this as abstraction layer so that I do not have to worry about what LocationProvider to use, behaves unexpectedly.
Scenario:
User opens app. I check for the availability of the providers and open the location settings page. The user enables "Access to my location" and both GPS and Wi-Fi location. When the user returns to the app I receive no location updates.
When I leave GPS turned off and only allow Wi-Fi in the System settings, I get an updated location.
I tried the priorities PRIORITY_LOW_POWER and PRIORITY_BALANCED_POWER_ACCURACY which both did not give me a location update when GPS was turned off.
How does it come, that the detection of the location works with GPS turned off and doesn't when it is turned on? Does that make any sense?
The location I obtain, when GPS is turned off is accurate enough for what the app is doing. If the device has had LocationServices turned on for a longer periods of time (Including the phone being outside) I receive Location Updates even with GPS turned on.
Does someone have an explanation for this / know how to solve this?
Related
I'm trying to develop an android application which can acquire GPS location without using Internet and even network location using SIM. Actually, SIM will be inserted in phone and i know that location upto 500m accurate can be acquired through it. But in case of no SIM signals in the area, is it possible to acquire location?
Yes, you can use GPS without any external data connection because signals from the GPS satellites are receive-only.
On a device, the permission setting is known as device-only location mode:
Device only
This mode uses only GPS. It doesn’t use Google's Location service to provide location information. It can estimate your device's location slower and use more battery.
Yes You can get the coordinates but for using map services you need internet.The only thing is your GPS will take a bit longer to lock your location on a cold start, and it might not be quite as accurate.
It's a aGPS (Assisted GPS), and get's part of the location information from the data network (If available) on cold start, then fine-tunes the location further than what a GPS alone can do.
Shouldn't be an issue however, really. Just turn your GPS on a little sooner (Like while getting ready to leave, not waiting until you are in your car).
Yes. If you use the Location Manager, set the Provider to LocationManager.GPS_PROVIDER. If you use Google Play Services, it should work automatically.
I would like to get the location of a smartphone (service runs in background) if location is turned off. Is there a way to automatically activate the Location service if it is turned off? For locating the user the FusedLocationProvider is used.
I guess that there is no chance to get the location by WiFi, GPS or cell towers if the location sensor is turned off.
The answer is you can't turn on the location automatically. The user has to give permission that's why it comes under PROTECTION_DANGEROUS.
Android is constantly changing. Currently, the Fused Location API is being used for location detection. But in my experience, without a Data connection, the GPS signal is not being found anymore.
How do I use the device's GPS only whenever there is no internet available?
Fused location provider uses a hybrid way to find gps using a variety of sensors, WIFI/data and the actual GPS chipset.
It will find the location COARSE/FINE accuracy is up to your case. It will just take a while longer than with the internet connection. If indoors or in an isolated area, it may very well take over a minute or two. Sometimes if the data signals just don't reach the device, yes it can fail.
It does work without WIFI or DATA in most cases.
The answer to the question here provides the method to activate the location if it has been turned off.
Now, Android has three location settings currently:
High Accuracy: Uses GPS, WiFi and cellular network to get the location.
Battery Saving: Uses cellular networks and WiFi to determine the location.
Device only: Uses GPS to determine the users location.
Checking the location status using the line:
gps_enabled = lm.isProviderEnabled(LocationManager.GPS_PROVIDER);
I redirect the user to the Activity where he can switch on the location. Now if the user turns on the location in the battery saving mode, will I get the location.
Also, for the redirection I do:
context.startActivity(myIntent)
Is there anyway to call startActivityForResult() here to verify if the user has turned on the location and depending on that redirect the user to different activities?
In Battery Saving mode GPS is OFF, so through GPS you will not get the location. but in Battery saving mode you can use WIFI and Mobile networks to determine the location
I am trying to get the user's current location using phonegap Geolocation api, which says "Common sources of location information include Global Positioning System (GPS) and location inferred from network signals such as IP address, RFID, WiFi and Bluetooth MAC addresses, and GSM/CDMA cell IDs". I am able to properly get the location when internet is ON (irrespective of the state of GPS).
Is there a way to get the location using triangulation when the internet is OFF or not accessible? (GPS might be ON or OFF)
A BIG "NO"! This is like cutting down hands and asking if I could clap now? GPS and NETWORK location providers are the only way to receive user device location.
For GPS location - you need GPS sensors to be ON.
And for NETWORK location you need to have internet connection ON, because in this case the location is calculated on the basis of Cell-Tower/Wifi-spot ID which is then sent to google servers (via internet) to fetch the location details of the respective Cell Tower or wifi spot. Google's location server have its own location approximation algorithms on the basis of which it tells your location.
So, there could be no way you could receive a location when both GPS and INTERNET are OFF.
Note: You can still get the last received location from any of these providers by using LocationManager's getLastKnownLocation() even when the providers are OFF. But this locations are usually outdated ones and are barely of any use.
{ enableHighAccuracy: true }
Enabling that option will allow the Android device to get the location even with the WIFI option disabled.